Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

asp.net

I am just simply 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....

like image 660
veda Avatar asked Dec 30 '25 19:12

veda


2 Answers

Use <br /> instead of \n.

like image 50
zs2020 Avatar answered Jan 01 '26 08:01

zs2020


To insert line breaks use the
tags.

To insert spaces use the  .

Label1.Text="First line<br/>Second line with &nbsp;&nbsp; more spaces"
like image 27
ZX12R Avatar answered Jan 01 '26 08:01

ZX12R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!