Last post Dec 22, 2009 07:57 AM by ilovenagpur
Aug 14, 2007 06:25 PM|avci|LINK
Hi, I am new at ASP.Net and I am wondering why we use literal. I read some documents and they say that literal's text value can be changed programatically but we can change a label's text property programatically too...
So can you please explain me briefly, why and when we should use the literal control?
Thank you very much in advance.
Aug 14, 2007 07:32 PM|d4dennis@inspir3|LINK
<asp:Label....Text="Hello World" ..> after render html <span >Hello World</span>
<asp:Literal...Text="Hello World" ..> after render html Hello World
* Label have property to apply style
* Label can be access via clientscript
** and many more
Hope this is Help!
literal vs label
Aug 14, 2007 07:37 PM|TonyMilne|LINK
The asp:Label control is used to label other elements on the page (similar to an html label). In fact, when you set the AssociatedControl property, the asp:Label produces an html label as its output. (You can omit the AssociatedControl property, and your
Label text will instead be wrapped in a span).
An asp:Literal control doesn't have any visual appearance on a page, but can be used to insert literal text. As such, the asp:Literal control can be used to insert html code directly in to the page.
You should use an asp:Label to give meaning to all form elements, eg: Textbox, Checkbox etc.
You could use an asp:Literal when you need to insert a value, or some html into your page.
Hope this helps,
Jun 02, 2008 07:28 AM|SheoNarayan|LINK
If you are still looking for the difference between the two in depth, you may visit to following link [:)]
Label Control :
Literal Control :
Jul 29, 2008 11:09 AM|Zenthil|LINK
Thanks. This is the good example. literal we cannot do the back color. It is the light weight server control.
Jul 28, 2009 01:34 AM|pawan kamar|LINK
Well i m also new in the .Net field. As far my knowledge, there is not any vast difference between label and literal. If i got more info i will surely tell you.
Dec 22, 2009 07:57 AM|ilovenagpur|LINK
You can get more info about the difference at :
At this Link