I want to show new line in label using c# but it's not working in every browser.
I want to show in xml format in browser.
My Code as below
lblSaleData.Text ="" + "\n" + "" + eml + "" + "";
I want to show new line in label using c# but it's not working in every browser.
I want to show in xml format in browser.
My Code as below
lblSaleData.Text ="" + "\n" + "" + eml + "" + "";
Try This It ll work in most browser..
lblSaleData.Text = "<Sales>" + "<br/>" +
" <eml>" + eml +
"</eml>" + "<br/>"+ "</Sales>";
If you want an HTML line break, use <br />
as suggested.
If what you want is to show nicely laid-out HTML source in a label, use System.Environment.Newline
. I normally stick it as a static readonly string NL
at the top of a file.
Looks like you're printing out XML on the screen, right? The Label control is automatically HTML-Encoding your text, so that the angle brackets aren't treated as html elements.
The newline character doesn't show on the screen, because <br />
is the correct html element for a newline.
I'd use:
lblSaleData.Text =String.Format("<Sales><br /><eml>{0}</eml></Sales>",eml);