Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between modes of literal control

What is the difference between the passthrough and Transform modes of literal control?

Could you post an example, too?

like image 627
Srivastava Avatar asked Sep 09 '10 04:09

Srivastava


People also ask

What is Literal control?

Literal control to reserve a location on the Web page to display text. The Literal control is similar to the Label control, except the Literal control does not allow you to apply a style to the displayed text. You can programmatically control the text displayed in the control by setting the Text property.

What are the properties that Literal control does not support?

You cannot apply a style to a literal control. Unlike Label control, there is no property like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. for Literal control.

What is Literal control in C#?

The Literal control is used to display text; that is, it renders static text on a Web page without adding additional HTML tags. It passes content directly to the client browser unless you use the Mode property to encode the content.


1 Answers

There are different Literal Modes Literal.Mode

  1. PassThrough : The contents of the control are not modified.
  2. Encode : The contents of the control are converted to an HTML-encoded string.
  3. Transform : Unsupported markup-language elements are removed from the contents of the control. If the Literal control is rendered on a browser that supports HTML or XHTML, the control's contents are not modified.

Have a look at this MSDN article http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.literal.mode.aspx

and take a look at this implemented example Use ASP.NET's Literal control to its full potential

like image 127
Muhammad Akhtar Avatar answered Oct 20 '22 00:10

Muhammad Akhtar