Multiline TextBox multiple newline Multiline TextBox multiple newline asp.net asp.net

Multiline TextBox multiple newline


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>


Try this one

textBox1.Text = "Line1" + Environment.NewLine + "Line2";

Working fine for me...