Nitin Kumar Nitin Kumar - 1 month ago 18
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

Nitin
Kumar
Shukla


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

try this

lll.Text = ttt.Text.Replace(Environment.NewLine, "<br />");
Comments