Carriage Return

  • Thread starter Barnabas (Barney) Yohannes
  • Start date
B

Barnabas (Barney) Yohannes

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.

Any help is highly appreciated,

Salutations
 
S

Scott Mitchell [MVP]

Barnabas said:
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
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top