Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Literal.Text Property

Gets or sets the caption displayed in the Literal control.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

[LocalizableAttribute(true)] 
[BindableAttribute(true)] 
public:
virtual property String^ Text {
	String^ get () sealed;
	void set (String^ value) sealed;
}
/** @property */
public final String get_Text ()

/** @property */
public final void set_Text (String value)

public final function get Text () : String

public final function set Text (value : String)

Not applicable.

Property Value

The caption displayed in the Literal control.

Use the Text property to specify or determine the caption displayed in the Literal control. This allows you to programmatically change the caption at run time.

The caption is HTML-decoded depending on how you assign a value to this property. If you assign a value through an attribute of the Literal control, the value is HTML decoded before it is displayed. For example, <asp:Literal id="DisplayLiteral" Text="A&nbsp;B"/> is rendered as "A B" on the browser. However, if you set this property programmatically or by placing the text between the opening and closing tags of the control, the caption is not HTML decoded. For example, <asp:Literal id="DisplayLiteral"> A&nbsp;B </asp:Literal> is rendered as "A&nbsp;B".

Caution noteCaution:

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, see Validation Server Controls.

The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see LocalizableAttribute and ASP.NET Globalization and Localization.

TopicLocation
How to: Add Literal Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications
How to: Add Literal Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications

The following example demonstrates how to use the Text property to programmatically change the caption displayed in the Literal control.

NoteNote:

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.

No code example is currently available or this language may not be supported.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft