Barnabas (Barney) Yohannes wrote:
> Please help me how I can enter text with carriage returns into my database.
>
> I have a Textbox with TextMode="MultiLine"
>
> Now, if inter a text with a carriage return, then, after I enter the text into SQL Server database, when I retrieve the text, I get the text in unwrapped format. Therefore, I have been entering the text with <br> html so that the text will read on the next line.
>
> I was thinking if there is a way to put my text into a loop and search for any carriage return and insert <br> in the place of each carriage return.
You can use the string class's Replace method. Assume str contains the
textbox value:
'VB.NET code follows....
str = str.Replace(vbCrLf, "<br>") ' replaces carraige returns with <br>
' -or-
str = str.Replace("<br>", vbCrLf) ' replaces <br>s with carraige eturns
In C#, you'd use "\r\n" instead of vbCrLf...
Happy Programming!
--
Scott Mitchell
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com
* When you think ASP, think 4GuysFromRolla.com!