Multiline Textbox and Databases

Last post 12-29-2005 11:58 AM by jcasp. 4 replies.

Sort Posts:

  • Multiline Textbox and Databases

    12-28-2005, 5:22 PM
    • Member
      5 point Member
    • Paul Samways
    • Member since 12-28-2005, 10:19 PM
    • Posts 1
    I have a form which contains multiline TextBoxes, which is used to put stuff into a database. This works fine, but I am having trouble displaying the Data, Whilst still keeping any New Lines that the user had entered.
  • Re: Multiline Textbox and Databases

    12-28-2005, 5:38 PM
    • All-Star
      30,698 point All-Star
    • StrongTypes
    • Member since 12-13-2005, 4:21 PM
    • California
    • Posts 6,007
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    You should use an HTML textarea instead of a multiline textbox if you want breaks between lines.

    HTML TextArea

    HTH

  • Re: Multiline Textbox and Databases

    12-29-2005, 2:48 AM
    • Member
      60 point Member
    • skipster2k2
    • Member since 05-03-2005, 10:51 AM
    • sunny plymouth
    • Posts 12

    Not really a solution more an observation... Ive had the same problem when putting values into a multiline textbox it doesnt keep any of the line breaks in when returning the values to a listbox or datagrid or a datalist, however if you return the values back to a different textbox it does keep the line break?!?!? our SQL dude here told me I would need to use the vbCrLf  command. I havent got round to figuring out how to use this command in my code yet though. When I do I will postback my set you off in a good direction for the time being, if anyone thinks I'm talking nonsense though please say as I'm not entirely sure this is the right way to go.

    Cheers Skippydee!

  • Re: Multiline Textbox and Databases

    12-29-2005, 7:47 AM
    • All-Star
      49,303 point All-Star
    • Curt_C
    • Member since 07-23-2003, 8:27 PM
    • Plover, WI - USA
    • Posts 5,357
    • Moderator
    What it boils down to is whether the control uses the standard linebreak or if it uses the <br> (also the <p>, etc). Some controls, like the multi-line textbox use the linebreak. Some, like the textarea control, use <br> and some dont accept any linebreaking (listbox I believe). This is part of why its important to thing about what control you need for what usage.
    Blatant Self-Promotion: Book Released - ASP.Net CMS Development
  • Re: Multiline Textbox and Databases

    12-29-2005, 11:58 AM
    • Star
      11,530 point Star
    • jcasp
    • Member since 04-10-2003, 6:43 AM
    • Posts 2,286

    << You should use an HTML textarea instead of a multiline textbox if you want breaks between lines. >>

    From what I can gather, this is not a different solution since multiline textbox is represented by HTML textarea already when presented to the browser.  Line breaks are represented by /r/n character combination which often have to be replaced by <br> prior to being displayed.  I wish the powers that be can one day remove this issue since so many people are having problems with it.

Page 1 of 1 (5 items)