The Literal control of ASP.NET 2.0
@ Add a Literal Web server control to your page when you want to set text programmatically without adding extra HTML tags. The Literal control is useful as a way to add text into a page dynamically without adding any elements that are not part of the dynamic text. For example, you can use the Literal control to display HTML that you read from a file or from a stream.
@ If you want to display static text, you can present it using HTML; you do not need a Literal control. Use a Literal control only if you need to render text programmatically.
@ You can use a Literal Web server control as a container for other content on the page. The Literal control is used most frequently when adding content dynamically to the page.
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.