Literal Control

- The Literal control is used to display text on a page. The text is programmable.
- This control does not let you apply styles to its content!
Property |
Description |
id |
A unique id for the control |
runat |
Specifies that the control is a server control. Must be set to "server" |
Text |
Specifies the text to display |

- Open Visual Studio
- Add a new webform
- Name it literal.aspx
- Click the Add button
- Select the Design View
- Add a label control and name it myLabel
- Add a literal control to the webform and name it myLiteral
- Erase the text in both controls

- Double-click the form and add this code:
myLabel.text=”Label Example”
myLiteral.text=”Literal Example”

right click and view in Browser
now right click the browser and view source

Notice the Label is displayed in a <span> tag
But the literal is just displayed
A literal control displays ONLY the value in the text property
