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?
A multiline text box allows you to display more than one line of text in the control. If the WordWrap property is set to true , text entered into the multiline text box is wrapped to the next line in the control.
Of course, there are situations in which there is need to add line breaks. You can do so by simply hitting Shift + Return or Shift + Enter , respectively.
To create a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows. Specifies that on page load the text area should automatically get focus.
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>
textBox1.Text = "Line1" + Environment.NewLine + "Line2";
Also the markup needs to include TextMode="MultiLine" (otherwise it shows text as one line)
<asp:TextBox ID="multitxt" runat="server" TextMode="MultiLine" ></asp:TextBox>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With