Carriage Return

Discussion in 'ASP .Net Datagrid Control' started by Barnabas (Barney) Yohannes, Mar 4, 2004.

  1. 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
     
    Barnabas (Barney) Yohannes, Mar 4, 2004
    #1
    1. Advertising

  2. 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!
     
    Scott Mitchell [MVP], Mar 4, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ferdi
    Replies:
    5
    Views:
    4,735
    Jacob Yang [MSFT]
    Aug 24, 2003
  2. Kevin Spencer
    Replies:
    3
    Views:
    3,264
    Doc Wally
    Oct 11, 2003
  3. Jeff Clark
    Replies:
    0
    Views:
    1,622
    Jeff Clark
    Oct 17, 2003
  4. Xeno Campanoli
    Replies:
    0
    Views:
    249
    Xeno Campanoli
    Feb 13, 2006
  5. Steve Anderson
    Replies:
    3
    Views:
    283
    Steve Anderson
    Jun 21, 2004
Loading...

Share This Page