System.Web.UI.WebControls.LiteralMode Enumeration

Specifies how the content in a System.Web.UI.WebControls.Literal control is rendered.

Syntax

public enum LiteralMode

Remarks

The System.Web.UI.WebControls.LiteralMode enumeration represents the modes that you can specify for how the content in a System.Web.UI.WebControls.Literal control is rendered. The Literal.Mode property uses these enumeration values to set the behavior of the contents of the Literal.Text property in a System.Web.UI.WebControls.Literal control.

If you specify PassThrough, the entire contents of the Literal.Text property are passed to the device or browser without any modifications. For example, if the Literal.Text property of a System.Web.UI.WebControls.Literal control contains an <hr> tag, it is sent to all devices and browsers regardless of whether it is supported.

If you specify Encode, the contents for the Literal.Text property are converted into an HTML-encoded string before rendering. For example, if the Literal.Text property of a System.Web.UI.WebControls.Literal control contains an <hr> tag, it will be converted to &lt;hr&gt; and sent to the device or browser.

If you specify Transform, the rendering behavior of the Literal.Text property depends on the type of markup being rendered. When the System.Web.UI.WebControls.Literal control is rendered for a device or browser that supports HTML or XHTML, specifying LiteralMode.Transform produces the same behavior as specifying LiteralMode.PassThrough. All markup tags and elements for the Literal.Text property are rendered for the requesting browser.

When the System.Web.UI.WebControls.Literal control is rendered for a markup language other than HTML or XHTML, such as WML or cHTML, you can use the LiteralMode.Transform value to remove unsupported markup elements. In this case, any markup-language elements of the Literal.Text property that are not supported in the targeted markup language are not rendered for the control. For example, if the Literal.Text property of a System.Web.UI.WebControls.Literal control contains an <hr> tag, the tag is removed before the content is sent to a WML device. If an unsupported tag contains content, only the tag is removed and the content is sent to the device or browser. For example, if the Literal.Text property contains the content <XYZ>Test</XYZ>, the <XYZ> and </XYZ> tags are removed while the text Test is sent to the device or browser.

Members

Member NameDescription
Encode

The literal control's contents are HTML-encoded.

PassThrough

The literal control's contents are not modified.

Transform

The literal control's unsupported markup-language elements are removed. If the literal control is rendered on a browser that supports HTML or XHTML, the control's contents are not modified.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0