开发者

asp.net : I wanted to know how to insert '\n' on the label

开发者 https://www.devze.com 2022-12-26 17:57 出处:网络
I am just 开发者_如何学Csimply creating a web application. I wanted to insert a line break in a label

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 &nbsp;&nbsp; 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消