How do convert text to HTML?

  • Thread starter Thread starter BADEV
  • Start date Start date
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.
 
Checkout the System.Web.HttpServerUtility.HTMLEncode function ...

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

Alex Papadimoulis
 
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.
 
Thanks, that did the trick. I just have to fix the
styles now :-) but that's an simpler problem.
 
Back
Top