Multiline TextBox multiple newline

2019-01-14 06:41发布

I set a value for a Multiline Textbox like this.

textBox1.Text = "Line1\r\n\r\nLine2";

But, only one line space in output.

When I read the value of textbox, I read "Line1\r\nLine2";

Why does ASP.NET not support more then one lineline character?

7条回答
混吃等死
2楼-- · 2019-01-14 07:09

You need to set the textbox to be multiline, this can be done two ways:

In the control:

<asp:TextBox runat="server" ID="MyBox" TextMode="MultiLine" Rows="10" />

Code Behind:

MyBox.TextMode = TextBoxMode.MultiLine;
MyBox.Rows = 10;

This will render as a <textarea>

查看更多
登录 后发表回答