Reputation: 2407
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.
Upvotes: 0
Views: 2129
Reputation: 2407
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
Upvotes: 1