tags:

views:

318

answers:

2

I could have sworn i have done this somewhere - im using 2.0 right now - was this something i found in a later version? IE: pass the content of a Literal in the constructor

I remember myself saying 'huh, and all this time i created a new instance and then set the text property' - or did I go to sleep drunk that night? And if not, WHY NOT!!!

+2  A: 

Maybe LiteralControl?

this.Controls.Add(new LiteralControl("<b>hello there</b>"));

Note it doesn't maintain ViewState so it must be added on each request.

Corbin March
Ahhh, thank you so much, thats what it was. I am sane :-)
schmoopy
Sanity is subjective. ;)
Erik Forbes
A: 

I don't know about calling new Literal("...") and I'm not exactly sure what you are after but the first thing that comes to my mind is the C# verbatim string.

string s = @"<b>hello there</b>";

Check out http://msdn.microsoft.com/en-us/library/aa691090.aspx for the C# string specification.

Wes Haggard