Newline has no effect in form fields

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";
}
}
 
D

David

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?
 
D

DBC User

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.
 
D

DBC User

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.
 
J

James Curran

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/>"
 
D

David

Yes this is an ASP.Net application, and using the html newline code did
the trick.

Thanks a lot guys.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top