Literal Class
Assembly: System.Web (in system.web.dll)
Use the System.Web.UI.WebControls.Literal control to reserve a location on the Web page to display text. The Literal control is similar to the Label control, except the Literal control does not allow you to apply a style to the displayed text. You can programmatically control the text displayed in the control by setting the Text property.
Caution: |
|---|
| This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. |
For more information about security, see Securing Standard Controls, How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings, and Introduction to Validating User Input in ASP.NET Web Pages.
The following example demonstrates how to use the Literal control to display static text.
Note: |
|---|
| The following example uses the single-file code model and might not work correctly if copied directly into a code-behind file. This code example must be copied into an empty text file that has an .aspx extension. For more information about the Web Forms code model, see ASP.NET Web Page Code Model. |
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand. Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand. Permission value: Minimal.
System.Web.UI.Control
System.Web.UI.WebControls.Literal
System.Web.UI.WebControls.Localize
Reference
Literal MembersSystem.Web.UI.WebControls Namespace
Label
Text
Other Resources
Literal Web Server Control OverviewSecuring Standard Controls
How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings
Introduction to Validating User Input in ASP.NET Web Pages
Literal Web Server Control
Caution:
Note: