Newline has no effect in form fields

  • Thread starter Thread starter David
  • Start date Start date
D

David

When I include a "\n", "\r\n" or a System.Environment.Newline in a
string value, and assign that to a form field, no newline appears at
that point in the text. I have done this in the past with a vbCrLf in
VB.Net, and as far as I know the "\r\n" should be equivalent, but it
doesn't work.

Any help would be appreciated.

Below find some sample code:

foreach(DataRow row in dt.Rows)
{
lbOutput.Text += row["Value"] + "\r\n";
}
}
 
Thanks, I did try this with a text box and it works. However, I want to
do this for other form fields like a label, for which I find no
multiline property. Also I want to be able to do newlines within the
cells of a datagrid.

Does anyone know if there is a way to do this?
 
I wrote a test for label and it seems to be working. Here is the code.

label1.Text = "DBC\nUser". It prints it in 2 lines. Remember, you need
to have enough vertical space to display both lines.
 
I am not sure my response got posted.

I tried a label as well with the following code

label1.Text = "DBC\nUser";

it got printed in 2 lines. Only thing in this case, you have to make
sure is, you have enough veritical heights to print two lines. You do
not need to use \r, that is line feed.
 
Is this an ASP.NET application? If so, you'd need to write HTML into
the label, so for a line break, you'd need to insert the string "<BR/>"
 
Yes this is an ASP.Net application, and using the html newline code did
the trick.

Thanks a lot guys.
 
Back
Top