Lets say I have a multiline
textbox and a user types a message in there. I want to save the message in the
database but
preserve formatting when the message is displayed at a later
time. I'm currently storing the message as an
nvarchar but none of the formatting line breaks get
preserved. Any ideas on how to do this?
Faruk
Member
2 Points
10 Posts
PRESERVING LINE BREAK IN MULTI LINE TEXT BOX
Apr 28, 2008 12:00 PM|LINK
Lets say I have a multiline textbox and a user types a message in there. I want to save the message in thedatabase but
preserve formatting when the message is displayed at a later
time . I'm currently storing the message as an
nvarchar but none of the formatting line breaks get
preserved. Any ideas on how to do this?
Mikesdotnett...
All-Star
154927 Points
19867 Posts
Moderator
MVP
Re: PRESERVING LINE BREAK IN MULTI LINE TEXT BOX
Apr 28, 2008 12:15 PM|LINK
http://www.mikesdotnetting.com/Article.aspx?ArticleID=20
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
Hua-Jun Li -...
All-Star
75950 Points
5608 Posts
Re: PRESERVING LINE BREAK IN MULTI LINE TEXT BOX
Apr 30, 2008 03:33 AM|LINK
Hi Faruk,
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(" "," ");
temp = temp.Replace("\r\n","<br>");
Then you can save it into database, and display it, it will ok.
Let me know if I have misunderstood what you mean.
Thanks.
Hope it helps,
Hua Jun
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
Jigarpatel
Participant
1411 Points
237 Posts
Re: PRESERVING LINE BREAK IN MULTI LINE TEXT BOX
Apr 30, 2008 03:56 AM|LINK
Hi Faruk,
Do like this...
thats it...
if this post helps you..
"Mark as Answer"
Web Developer
India