replacing EOL with <br>

D

Daves

would there be any neater way to replace EOL codes with <br> than this?

<asp:Label ID="Label1" Runat="Server"><%#
(Eval("Content")).ToString().Replace("\n", "<br>") %></asp:Label>
 
K

Karl Seguin

Use a function

<asp:Label ID="Label1" Runat="Server"><%# FormatContent(Eval("Content"))
%></asp:Label>

protected stirng FormatContent(string content){
if (content == null) return "";
return content.Replace(System.Environment.NewLine, "<br>");
}

you can check out: http://openmymind.net/MyArticles.aspx?documentId=8 for
more information

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top