Monday, May 11, 2009

Difference between Label and Literal in ASP.NET

ASP.NET is rich on user controls, there are many controls availabe to use in web form.
like as
1. Literal
2. Label
Literal and label are used to display plain text in the website. But it has some inherit differences. Label automatically takes XHTML control which make the text's look and feel better. where as literal doesnot take that tag so became thin text. But it is more usable for some place where XHTML is not possible to use like as head of the web forms.

if we need to change the head of page dynamically then literal only the option rather than label

e.g.
<-head>
<-title><-asp:literal id="literal1" runat="server" text="this is text for display"><-asp:literal>
<-/title>
<-/head>

No comments:

Post a Comment