Nitin Kumar Nitin Kumar - 1 year ago 128
ASP.NET (C#) Question

Unable To Show Multiline Textbox text with new line in Label

If i enter below text in my multi line textbox


then i got this result

Nitin Kumar Shukla

but i want result same as i write in my multi line textbox

Here is my aspx page code

<asp:TextBox ID="ttt" TextMode="MultiLine" runat="server"></asp:TextBox>
<asp:Button ID="btn" runat="server" Text="hjhj" onclick="btn_Click" />
<asp:Label ID="lll" runat="server"></asp:Label>

here is my cs page code

protected void btn_Click(object sender, EventArgs e)
lll.Text = ttt.Text;

Answer Source

try this

lll.Text = ttt.Text.Replace(Environment.NewLine, "<br />");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download