Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I try to show the program text in a web page just like CodeProject; however, somehow I just can not get the right combination! I tried all 4 combinations with no result. What is the secret?


XML
<%
CR = chr(10)

Text = "<table border=""1"" bordercolor=""#660066"">" & CR
Text = Text & "<tr><td>test line 1</td></tr>" & CR
Text = Text & "<tr><td>test line 2</td></tr>" & CR


        NText = replace(text, "<", "&lt;")
        Ntext = replace(Ntext, ">", "&gt;" )
        Ntext = replace(Ntext, "&", "&amp;")
        Ntext = replace(Ntext, """", "&quot;")
        Ntext = replace(Ntext, Chr(10), "<br>")


%>
<table border="1" bordercolor="#FF0000">
<tr><td>
<b>Original No Pre</b><br><%=text%>
</td></tr>
<tr><td>
<b>Original wz Pre</b><br><pre><%=text%></pre>
</td></tr>
<tr><td>
<b>Converted No Pre</b><br><%=ntext%>
</td></tr>
<tr><td>
<b>Converted wz Pre</b><br><pre><%=ntext%></pre>
</td></tr>
</table>


rgds,
kfl.
Posted

You have to define the styles for the different tag types in a Stylesheet to customize the formatting and then include that in your web control/form.
 
Share this answer
 
v2
Comments
KFLee 26-Nov-10 5:10am    
can you be more specific?
XML
<textarea name="sample" width=38 height=10>
<%= Server.HTMLEncode(sValue) %>
</textarea>


VB
Function HTMLDecode(sText)
    Dim I
    sText = Replace(sText, "&quot;", Chr(34))
    sText = Replace(sText, "&lt;"  , Chr(60))
    sText = Replace(sText, "&gt;"  , Chr(62))
    sText = Replace(sText, "&amp;" , Chr(38))
    sText = Replace(sText, "&nbsp;", Chr(32))
    For I = 1 to 255
        sText = Replace(sText, "&#" & I & ";", Chr(I))
    Next
    HTMLDecode = sText
End Function


You can do it on client-side with javascript functions
 
Share this answer
 
Comments
KFLee 15-Mar-11 12:30pm    
thanks, have not visit codeproject for sometime; will test it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900