tags:

views:

574

answers:

4

How do you usually convert line breaks in a form textbox or input=text element to html line breaks?

Thanks

Edit: Is it always \r\n with all browsers?

+1  A: 
Replace(vbcrlf, "<br />")
Shawn Simon
+5  A: 

Or in C#:

myString.Replace("\r\n", "<br />");

If you're worried about it being different on different platforms, you could also do:

myString.Replace("\r\n", "<br />");
myString.Replace("\n", "<br />");
myString.Replace("\r", "<br />");
amdfan
+3  A: 

Is it always \r\n with all browsers?

This is handled on the server, it has nothing to do with browser. However I would suggest using:

System.Environment.NewLine
DaRKoN_
A: 

Depending on the scenario this could also work:

MyString.Replace(Chr(10), "<br/>")
JordanC