Difference between label and literal controls in asp.net?

 Posted by aswinialuri-19361 on 4/23/2013 | Category: ASP.NET Interview questions | Views: 1494 | Points: 40
Answer:

label:
Label control renders text within span tag to browser. It is possible to apply style and style sheet class to label.
Literal:
Literal will render it's text that is assign to text property. It cannot render any additional html tag. Default mode for literal is “Transform”. Best practice to set Mode="Encode" for literal control

It is best practice to use literal instead of Label control wherever it possible in asp.net application.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response