I am using a p tag with id p1.
<p id="p1" runat="server" ></p>
I have a message which I am passing from server side which is stored in variable "message".
This is first line
This is second line
I am passing this value to the p tag by
p1.InnerText=message.
My question is, How to add new line in the p tag from server side as shown above?
I have tried
but it is not working :
"This is firstline"+"<br/>"+"This is second line"
If you want new lines in the original string to be shown in the paragraph, you must use the
InnerHtml
property and add<br />
tags instead of newline chars/strings. But that means you need to take care of html encoding the strings yourself. Something like this would work:Test it: