Literal Example in ASP.NET using C#

Literal Example in ASP.NET using C#


Posted in : ASP.Net Posted on : November 26, 2010 at 5:55 PM Comments : [ 0 ]

In this article we will introduce with Literal control in ASP.NET using C#.

Literal Example in ASP.NET using C#

Literal control in ASP.NET doesn't have any appearance on a web form but it is used to insert a literal text. You can edit the HTML control with literal text but it depends on the Mode property of the Literal control. Literal control has the following three Mode.

1. Transform: Any markup you add to the control is transformed to accommodate the protocol of the requesting browser.
2. PassThrough: Any markup you add to the control is rendered as-is to the browser.
3. Encode: This mode converts to any markup into its text representation . for example: <b>

Literal.aspx (Design Page):

Literal.aspx (source code):

<%@ Page Title="" Language="C#" MasterPageFile="~/RoseindiaMaster.master" 
AutoEventWireup="true" CodeFile="Literal.aspx.cs" Inherits="literal" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div>
<h2 style="color:Green">Literal in ASP.NET 4 , C#</h2>
Transform Mode:
<br />
<asp:Literal ID="literal1" Mode="Transform" Text="<b>This is Devmanuals.com</b>" 
runat="server" />
<br />
<br />
Pass Through Mode:
<br />
<asp:Literal ID="literal2" Mode="PassThrough" Text="<b><u>This is Devmanuals.com</b></u>" runat="server" />
<br />
&nbsp;&nbsp;&nbsp;
<br />
Encode Mode:
<br />
<asp:Literal ID="literal3" Mode="Encode" Text="<b>This is Devmanuals.com</b>" 
runat="server" />
</div>
</asp:Content>

<br />
<asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="#000099" />
</asp:Content>

Output:

Download source code
Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics