PDA

View Full Version : print html


alaios
04-01-2003, 06:51 PM
i want to store into a variable the stirng
a="<b>bold text</b>"
And when i write Response.write a
The text apears in bold as html
How i can do it?

BigDaddy
04-01-2003, 07:34 PM
a = "<b>Your message here</b>"

response.write a


You pretty much had it already. Did you try it? Was it not working?

oracleguy
04-01-2003, 09:15 PM
Also instead of response.write a you can just do <%= a %> if you want to insert the text in the middle of something.

whammy
04-01-2003, 11:59 PM
Also, something like this might be useful if you needed to bold different variables...


<%
Function Bold(ByVal str)
If IsNull(str) Then Exit Function
Bold = "<b>" & Server.HTMLEncode(str) & "</b>"
End Function
%>

<% = Bold("Yay!") %>

alaios
04-02-2003, 05:12 AM
what is this ? Server.HTMLEncode(str)???
Thx

raf
04-02-2003, 06:59 AM
It's a function you silply must use on allmost every value from a textvariable that you sent to the browser.

If you run a search on this forum, you'll know why --> security, displaying all sort a symbols right ...

info from the helpfile
----------------------------------------------------

HTMLEncode
The HTMLEncode method applies HTML encoding to a specified string.

Syntax
Server.HTMLEncode( string )

Parameters
string
Specifies the string to encode.
Example
The following script

<%= Server.HTMLEncode("The paragraph tag: <P>") %>

produces the output

The paragraph tag: &lt;P&gt;

Note The preceding output will be displayed by a Web browser as

The paragraph tag: <P>

If you view source, or open the page as a text file, you will be able to see the encoded HTML.