|
Label
The Label Web Server control is used to label other parts of the application. They
are used to display text which the user can't change. To display text on a label we
use the text property. The class hierarchy for this control
is as follows:
Object
Control
WebControl
Label
A label control with BorderStyle property as solid and BorderColor property
as blue is shown below.
I
am Label
Literal
A Literal Web Server control doesn't have any visual appearance on a Web Form but is
used to insert literal text into a Web Form. This control makes it possible to add
HTML code directly in the code designer window without switching to design view and
clicking the HTML button to edit the HTML. The class hierarchy for this control is
as follows:
Object
Control
Literal
The notable property of this control is the text property
which is the text that is inserted into the Web Form. A literal control with text
"I am Literal" is displayed below.
I am Literal
Editing HTML with Literal Control
As mentioned above, we can use a literal control to edit the HTML directly in the
code designer. The following line of code demonstrates that.
|
Literal1.Text = "<b><u>I am Literal</b></u>"
|
To test the above line of code click the button below. The text "I am Literal" displayed beside
the Button will be underlined and will be displayed in bold format. The difference
is we added HTML code directly in the code designer window instead of switching and
editing it in HTML view.
Live Code Demo
I am Literal
|