HTML formatting using textarea

Last post 07-08-2009 4:25 AM by Hua-Jun Li - MSFT. 3 replies.

Sort Posts:

  • HTML formatting using textarea

    07-03-2009, 5:28 AM
    • Member
      6 point Member
    • matthisco
    • Member since 06-04-2008, 11:21 AM
    • Posts 159

    Can anyone please tell me how I can keep basic html formatting when using a text area and submitting to a database?

    I'd like to store linebreaks and paragraphs when submitting the form.

    Thankyou

  • Re: HTML formatting using textarea

    07-03-2009, 6:24 AM
    Answer
    • All-Star
      91,085 point All-Star
    • vinz
    • Member since 10-05-2007, 3:47 PM
    • Cebu, Philippines
    • Posts 13,713
    • TrustedFriends-MVPs

    matthisco:

    Can anyone please tell me how I can keep basic html formatting when using a text area and submitting to a database?

    I'd like to store linebreaks and paragraphs when submitting the form.

    AFAIK, MultiLine TextBox doesn't supports HTML formatting.. You would need to use Rich Text editor such as fckEditor or FreeTextBox to display formatted text..

    See this link to see the list of Editors:

    Lists of WYSIWYG Editor


    "Code,Beer and Music ~ my way of being a programmer"

  • Re: HTML formatting using textarea

    07-03-2009, 6:24 AM
    Answer
    • All-Star
      20,622 point All-Star
    • venkatu2005
    • Member since 07-01-2008, 10:48 AM
    • Posts 4,514

    matthisco:

    I'd like to store linebreaks and paragraphs when submitting the form.

    Thankyou

    have you check the while you store the textarea data to database , ie: which format your data will be.. put breakpoint and check it

    This is code which provide break for new line

    C#

    Label1.Text= Label1.Text("\r\n" , "<br\>");

    in vb.net

    Label1.Text= Label1.Text(vbCr & vbLf , "<br\>");

    and vice versa


    I have Changed My Blog from (http://venkat-dotnetsamples.blogspot.com) to (http://venkat-dotnetsnippets.blogspot.com)

    Regards,
    Venkatesan.M

    Please Mark as Answered If its helpful and Un-Mark as Answered if it not help u.
  • Re: HTML formatting using textarea

    07-08-2009, 4:25 AM
    Answer

    Hi matthisco,

    If you input some text into textbox, and save the message in the database.

    You should handler the message before saving the message into database.

        temp=TextBox1.Text;
        temp = Server.HtmlEncode(temp);
     temp = temp.Replace(" ","&nbsp;");
     temp = temp.Replace("\r\n","<br>");

    Then you can save it into database, and display it, it will ok.

    Sincerely,
    Hua Jun Li
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (4 items)