28 August 2008

Support you have a textbox and you want to display it's value in a label, we can face this problem that it will not show new line.
this is because the code is something like this:

protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text;
}

but now change this code by :

protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text.Replace(Environment.NewLine, "
");
}

and see the result:

this is because if using "Environment" class.

0 comments :

Post a Comment