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
> 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
[quoted text clipped - 11 lines]
> message.Append("Line 2");
> Label.Text = message.ToString();
John Grandy - 26 Jul 2007 19:09 GMT
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 <span> with 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";
> First, this is really not a C# language group question and should probably
> have been directed to the ASP.NET newsgroup instead.
[quoted text clipped - 25 lines]
>> message.Append("Line 2");
>> Label.Text = message.ToString();