Tuesday, March 13, 2012

TextBox "Enters" in text

Hello,

I have a MultiLine TextBox which text should be send to a SQL 2005 Database Table. How can I preserve "enters" (for breaks and new paragraphs) so that when the text is shown from the database it has paragraphs?

Thanks in advance.


the linebreak from a multiline textbox is actually a CRLF (environment.newline).

when you render data that came from a multiline textbox and you want to show the carriage returns on the screen, you need to replace them with a break tag "<br />"

i.e.

myText = myText.Replace(Environment.NewLine, "<br />")


For reference, you might also want to check this thread on exactly the same subject from earlier today:

http://forums.asp.net/t/1153952.aspx

0 comments:

Post a Comment