I just wanted to hear some authorities on when and where you should use a LITERAL control over a LABEL.
As I understand it, the difference
Difference b/w Label and Literal Control in asp.net
In almost all ways a Literal control is the same as a Label control. Both of these controls are used to display Text on a webform. (The Text property can be set in the HTML or in the code-behind.)
The biggest difference is that the Label control wraps the text in a span when rendered. Any style that is applied to the Label control, will be rendered using the style property of the span.
For example, the following HTML
Will be rendered as
Label Text
A Literal control doesn't output any surrounding tags, so the Text is displayed as is:
For example, the following HTML
will be rendered as
Literal Control Text
So if you want to apply any styles to a than use Label control otherwise use the Literal control. Because of this, the Literal control is a light weight control, when compared with the Label control.
FYI: The inheritance hierarchy for Literal control class is (Object => Control => Literal), where as for the Label control, the hierarchy is (Object => Control => WebControl=> Label)