Last post May 04, 2009 07:23 AM by nareshprakash
Oct 05, 2004 08:56 AM|drock22|LINK
Oct 05, 2004 10:19 AM|zyxockjm|LINK
Oct 05, 2004 10:26 AM|max_at_aspnet|LINK
Oct 05, 2004 10:41 AM|max_at_aspnet|LINK
Oct 05, 2004 10:54 AM|drock22|LINK
Oct 05, 2004 11:02 AM|Blade2032|LINK
Oct 05, 2004 11:04 AM|max_at_aspnet|LINK
Oct 05, 2004 11:09 AM|SomeNewKid|LINK
Oct 05, 2004 11:57 AM|drock22|LINK
May 14, 2008 04:31 AMfirstname.lastname@example.org|LINK
It is better to use literal control rather than label control . Literal control is supposed to use because the page size will be less compared to label control.
If page size is more it ultimately affects performance of a application. Just try by taking few literal controls on a page and find out the size of the page. similarly take some label controls on to a page and find out size. U will know the difference.
Jun 02, 2008 07:43 AM|kamlapuri|LINK
You could use an asp:Literal when you need to insert a value, or some html into your page.
Jul 22, 2008 03:46 AM|asterix2008|LINK
One more difference I've just noticed:
asp:Literal does not have a "cssclass" property
asp:Label does have a "cssclass" property
...so if you're trying to output something with a unique style, using the asp:Label would be more appropriate.
...for what it's worth.
May 04, 2009 07:23 AM|nareshprakash|LINK
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.
Encoding Content in the Literal Control
The Literal control supports the Mode property, which specifies how the control handles markup that you add to it. You can set the
Mode property to these values:
Transform. Any markup you add to the control is transformed to accommodate the protocol of the requesting browser. This setting is useful if you are rendering content to mobile devices that use protocol other than HTML.
PassThrough. Any markup you add to the control is rendered as-is to the browser.
Encode. Any markup you add to the control is encoded using the HtmlEncode method, which converts HTML encoding into its text representation. For example, a
<b> tag is rendered as <b>. Encoding is useful when you want the browser to display markup rather than interpret it. Encoding is also useful for security, to help prevent malicious markup from being executed in the browser, and
is recommended if you are displaying strings from an untrusted source.