System.Web.UI.WebControls.Literal.Mode Property

Gets or sets an enumeration value that specifies how the content in the System.Web.UI.WebControls.Literal control is rendered.

Syntax

[System.ComponentModel.DefaultValue(System.Web.UI.WebControls.LiteralMode.Transform)]
public LiteralMode Mode { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

Use the Literal.Mode property to specify how the contents of a System.Web.UI.WebControls.Literal control should be rendered. This property is set using one of the System.Web.UI.WebControls.LiteralMode enumeration values. The following table lists the possible values.

PassThrough

The contents of the control are not modified.

Encode

The contents of the control are converted to an HTML-encoded string.

Transform

Unsupported markup-language elements are removed from the contents of the control. If the System.Web.UI.WebControls.Literal control is rendered on a browser that supports HTML or XHTML, the control's contents are not modified.

If you specify PassThrough, the entire contents of the Literal.Text property are passed to the device or browser without making 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 whether it is supported or not.

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 is 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, and the text "Test" is sent to the device or browser.

Requirements

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