I have an asp.net web form which on one page has a multi line textbox. When the user types in this field and continues the details are displayed on a confirmation page and displays as the user entered
Example
This is the first line
This is the second line
But when I click my edit button (which directs me back to my page) my textbox displays as
This is the first line
This is the second line
I want it to keep its styling but don't know how to do this. The details are stored in the session.
Code behind
protected void Step07SubmitButton_Click(object sender, EventArgs e)
{
Session["Step07OtherDetailsField"] = Step07OtherDetailsField.Text.Replace("\r\n", "
");
Response.Redirect("/Quotation/pg3.aspx");
}
I tried the following in my Page_Load
Step07OtherDetailsField.Text.Replace("
", "\r\n");
and also
Step07OtherDetailsField.Text.Replace("
", Environment.NewLine);
But for some reason when I debug it, it says that my .text is empty but the previous wording is actually still displayed in the field and the
is also still displayed.
Solutions1
You don't need to replace anything. You just store value in session and display it to any textbox, it will maintain \r and \t.
If you want to display result in span then display result to textbox with multiline then apply css for no border,etc.
Talk1:
I need to replace so that on my confirmation page it displays as the user entered it and is readable to them but as I said when I click my edit button (so the user can update it), it displays the
Talk2:
on your confirmation page this text is displayed on span or textbox?
Talk3:
If you want to display it on span then you have to replace other wise you bind value in textbox as it.
Talk4:
On my confirmation page it is displayed in a
Talk5:
I think you should display text in to textarea readonly in your confirmation page. so no need to replace words.