How to force newline content to appear in the next line in HTML

Posted by Poster under ASP.NET category on | Views : 7893
Generally when we write something in the HTML TextArea by pressing enter key and save into the database. It is saved with "\n" for every enter key press. When we render that content to the page "\n" is not converted to new line in HTML so we need to explicitly replace "\n" with "<br />". For example

        string s = "Your \n Data";
s = s.Replace("\n", "<br />");

Here Your will come as first line and Data will come as second line on the HTML page but if you would have written the s string without replacing both would have displayed in a single line.

Thank you.

Comments or Responses

Login to post response