I am just 开发者_如何学Csimply creating a web application. I wanted to insert a line break in a label
for example
label1.Text = "I AM HERE" + "\n" + "I AM NOW HERE";
I wanted to print it as
I AM HERE
I AM NOW HERE
But, it is not working... I don't know why...
I even tried
label1.Text = "I AM HERE" + '\n' + "I AM NOW HERE";
its not working.. What should I do....
Use <br />
instead of \n
.
To insert line breaks use the
tags.
To insert spaces use the .
Label1.Text="First line<br/>Second line with more spaces"
Use the <br />
tag. This will create a breaking space (or newline) in the label, e.g.:
label1.Text = "I AM HERE<br />I AM NOW HERE";
As a side note. You do not need to seperate out \n
's in your coding. In future where you can use it, you can simply go:
"I AM HERE\nI AM NOW HERE";
And this will add in the new line for you.
精彩评论