Difference between Label and Literal in Asp.Net | Label vs. Literal
Difference between Label and Literal in Asp.Net | Label vs. Literal
Label Control | Literal Control | |
---|---|---|
Text property | By default Text property of Label contains “Label1” | By default text property does not contains any text means It’s blank. |
Rendering | Label control is rendered as span tag. | Literal control does not add any HTML elements to the web page. |
Formatting Properties | You can apply any style property to the Label Control and also support formatting properties. | You can not apply any style property to the Literal Control i.e. this control does not support any formatting properties. |
Lightweight | Label control is less lightweight compare to Literal control. | Literal control is more lightweight compare to Label Control. |
Mode Property | Label control does not have mode property. | Literal control have mode property. |
In Title Tag | Label control can not be used in between title tag. | Literal control can be used in between title tag. |
Text to be Display | Label control enables to display static text on the web page. | The Literal control is used most frequently when adding content dynamically to the page. |
Class Hierarchy | The class hierarchy for Label control is as follows :
Object > Control > WebControl > Label |
The class hierarchy for Literal control is as follows :
Object > Control > Literal |