Sunday, April 17, 2011

Difference between Literal and Label in ASP.NET

Literal Control: It is used to display data; it is lightweight and does not make any formatting techniques. Literal control will render only its text which is assigned in its text property.

For example:
<div>
<asp: Literal ID="Literal1" runat="server" Text="This is a literal control">
</asp: Literal>
</div>

this code render as:
<div> This is a literal control</div> 
Label Control: It is also used for display data, it makes formatting techniques when it render. It will render text within span tag.

For example:  
<div>
<asp: Label ID="Literal1" runat="server" Text="This is a label control">
    </asp: Label>
</div>

this code render as:
<div><span>This is a label control </span></div> 

No comments:

Post a Comment

Ajax CalendarExtender displaying at wrong position in Chrome

< script type ="text/javascript" language ="javascript">     function onCalendarShown(sender, args)...