Literal

You can use a Literal control as a container for other content on the page. The Literal control is used most frequently when adding content dynamically to the page.

To add a Literal control to a page

  1. Drag the Literal control from the Toolbox panel to your page.

  2. Set properties for the control in the Tag Properties panel.

Common Literal Properties

Property Description

Text

Specifies the text displayed in the Literal control. In the user's browser, this is rendered as HTML.

Mode

Specifies how the control handles markup that you add to it. For details, see Literal Web Server Control Overview Cc295501.xtlink_newWindow(en-us,Expression.40).png in the MSDN library.

For a full description of all Literal control properties, see Literal Properties Cc295501.xtlink_newWindow(en-us,Expression.40).png in the MSDN library.

Comparing the Literal control to other options

The Literal control represents one of several options for adding content to a page. For static content, you can add markup directly to a page as HTML, without using a container. However, if you want to add content dynamically, you must add the content to a container. Typical containers are the Label control, the Literal control, the Panel control, and the Placeholder control.

The Literal control differs from the Label control in that the Literal control does not add any HTML elements to the text. (The Label control renders a span element.) As a consequence, the Literal control does not support any style attributes, including position attributes. However, the Literal control allows you to specify whether content is encoded.

The Panel and Placeholder controls render as DIV elements, which create discrete blocks in the page, unlike rendering in-line the way the Label and Literal controls do.

In general, use a Literal control when you want to render text and controls directly into a page without any additional markup.

See also

Concepts

Label
Panel
PlaceHolder

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.