Basically the label control is used for showing text content when asp:label render it will become span and literal control is used for displaying the html content and text also but if you trying to render html from label so it is also possible
like :
you hv a label so
label.text=""
literal.text=""
they both giving the same result and it is input box on page try it...
1. Label control (by default) is rendered as HTML Tag i.e. the Text is enclosed within the HTML Tags. When AssociatedControlID property is set for the Label control it is then rendered as HTML
2. Label control can be styled i.e. its Font, Color, Font Size, etc. can be easily changed.
3. Label control can be easily accessed via JavaScript or jQuery.
4. Generally used for displaying Text content on Web pages.
Literal control
1. Literal control is rendered as is i.e. it is not enclosed within any HTML Tags.
2. Literal control cannot be styled as it does not use any HTML tag.
3. Literal control in spite of giving ID is rendered without ID hence cannot be accessed via JavaScript or jQuery.
4. Generally used for adding HTML content on page for example suppose you want to add HTML
Tag and if you would use Label it would not be correct HTML since as per W3C Standards an HTML
cannot be rendered within a or tag.
The answer is helpful.Then please accept the answer..!!!
Shubham KumarRank #621 · 3.8K reputationPosted Sep 5, 2015, 7:58 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 5, 2015, 7:46 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts