Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have PrivateMessage-System in my new Community-Page.

I have a Multiline-Textbox for the Text of a private message. I save this text in a string, this string in a ntext SQL-Coloumn. I read this text from the ntext SQL-Coloum in a string and show it in a label.

When I have 5 linebreaks with the "Enter"-Key in my Multi-line-textbox, the linebreaks will disappeared in the label.

I don't know where they gone lost and what I am doing wrong. any idea?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

First of all is it actually saving the line breaks to your table? If so, what does it save them as, eg or CRLF or what?

Your label outputs html, so the only thing that will create a break is a <br /> tag. So you need to find and replace whatever is saved in the database:

Label1.Text = someDatabaseText.Replace("
", "<br />");

Or even better, do the .Replace() before you save it to the database:

someDatabaseField = TextBox1.Text.Replace("
", "<br />");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...