Yeah, wrong forum, whatever.
There's actually a decent reason why I thought \r\n would work.
The ASP.NET Label control performs magic behind the scenes, such as HTML
encoding, to ensure that content shows up right.
However, directly embedding <br/doesn't work , because ASP.NET renders the
Label control as a <spanwith literal content
<br/>
which will show on the web page as
<br/>
And of course performing the HTML encoding yourself makes matters even worse
:
Server.HMTLEncode("<br/>") is rendered as
amp;lt;br/amp;gt;
I was thinking the ASP.NET Label control would be smart enough to recognize
\r\n and render it as <br/ ... nope. I don't think an ASP.NET Label
control is capable of rendering the line breaks.
However, you can use a server-side span element ...
..aspx
<span id="span1" runat="server">
..aspx.cs
HtmlGenericControl span1;
span1.InnerHtml = "blah blah blah <br/blah blah blah";
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yohohhoandabottleofrum.comwrote
in message news:56**********************************@microsof t.com...
First, this is really not a C# language group question and should probably
have been directed to the ASP.NET newsgroup instead.
ASP.NET Label control will display HTML. "\r\n" is not html -- <BR/is.
Try that.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com
"John Grandy" wrote:
>I am not having success embedding carriage return and line feed
characters
into a string and displaying them with an ASP.NET label. Is anyone
getting
either of the following to work ?
StringBuilder message = new StringBuilder();
message.Append("Line 1");
message.Append("\r\n");
message.Append("Line 2");
Label.Text = message.ToString();
StringBuilder message = new StringBuilder();
message.Append("Line 1");
message.AppendLine();
message.Append("Line 2");
Label.Text = message.ToString();