PDA

Click to See Complete Forum and Search --> : what's a literalControl?


MrPolite
Jul 7th, 2003, 03:43 AM
stupid question, can someone tell me? :)

Lethal
Jul 7th, 2003, 08:24 AM
The literal control renders static text. for example:


<b>The literal control spit me out!</b>

hellswraith
Jul 7th, 2003, 11:30 AM
To go a little further, you can include html tags in the text so they will format the text when displayed.

LiteralControl lc = new LiteralControl("<b>This is going to show up bold</b>");

MrPolite
Jul 7th, 2003, 04:35 PM
umm thanks, second day working with asp.net:D still confused about a lot of stuff, hehe


edit: aah
I've got this stupid book, too easy, read 130 pages of it in a day:D
I dont understand why they used literalcontrol. They are just adding plain text (no formatting, no html tags) to a tablecell


Dim cellFont As New TableCell
' ff is just a fontFamily var
cellFont.Controls.Add(New LiteralControl(ff.Name))


' why dont they use this instead?
' cellFont.Text = ff.Name


what's the point of a literal control there?:rolleyes:

Lethal
Jul 8th, 2003, 07:45 AM
Remeber that we are working in an object oriented environment, and it is much cleaner using objects that simply using mass string concactenation.

MrPolite
Jul 8th, 2003, 05:32 PM
hmmmmmmmmmmmmmmmmmmmmmm ok :p

hellswraith
Jul 9th, 2003, 12:59 PM
To answer your question, I don't think their example needed the literal control at all. But there are a lot of other uses for it.