How do convert text to HTML?

B

BADEV

I've an multi-line edit box on an html page that I use to
collect detailed description information. I'd also like
to display that information on an html page... How do I
convert it to hmtl so that line feeds and other special
characters are displayed properly.
 
A

Alex Papadimoulis

Checkout the System.Web.HttpServerUtility.HTMLEncode function ...

eg, Label1.Text = HTMLEncode( Textbox1.Text )

Alex Papadimoulis
 
M

mikeb

BADEV said:
I've an multi-line edit box on an html page that I use to
collect detailed description information. I'd also like
to display that information on an html page... How do I
convert it to hmtl so that line feeds and other special
characters are displayed properly.

HttpUtility.HtmlEncode() will make it so special characters are
displayed properly.

Then try wrapping the text in <pre> </pre> tags. That will preserve line
breaks. If you don't like the text appearance used for the <pre>
element, you can use style sheets to change it, or perform a search and
replace to change line breaks (\n, \r\n, or whatever you decide is a
line break) to the "<br/>" tag.
 
G

Guest

Thanks, that did the trick. I just have to fix the
styles now :) but that's an simpler problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top