Literal Web Server Control

Displays static contents on the page and allows you to manipulate it programmatically.

<asp:Literal id="Literal1"
     Text="Text"
     runat="server"/>

Remarks

Use the Literal control to display static text on the Web Forms page. Unlike the Label control, Literal does not let you apply styles to its content.

Note   Text is not HTML encoded before it is displayed in the Literal control. This makes it possible to embed script within HTML tags in the text. If the values for the control come from user input, be sure to validate the values to help prevent security vulnerabilities.

Example

The following example demonstrates how to use the Literal control to display static text.

<html>
<head>
</head>
<body>
   <form runat="server">
      <h3>Literal Example</h3>
      <asp:Literal id="Literal1"
           Text="Hello World!!"
           runat="server"/>
   </form>
</body>
</html>

See Also

Web Server Controls | Literal Class