0

I have the following textbox:

<asp:TextBox  ID="txtText" runat="server" Height="135px" 
    Width="355px" TextMode="MultiLine"></asp:TextBox><br /><br />

how can I save the formatted text (text with line spacing mostly) and display it in another div/label or save it in database?

I tried to save it database using both nvarchar or text data but text is being passed as a one liner all the time.

3
  • 1
    data but text is being passed as a one liner all the time. How exactly did you verify this? Commented Oct 16, 2013 at 13:30
  • check this thread: stackoverflow.com/questions/13638169/… Commented Oct 16, 2013 at 13:30
  • @asawyer breakpoints and assiging the texbox text to div/label directly on button click Commented Oct 16, 2013 at 13:42

1 Answer 1

1

Solved this by saving the text in a string and replacing \r\t with <br/> before saving to the database:

string text = txtText.Text;
text = text.Replace("\r\n", "<br/>");
//save to database
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.