Hi,
Why Literal control is used? How to work with this control? Plz, explain with simple example.
Thanks.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 5, 2012, 7:36 PM EST
The Literal control is used to display text on a page.
Example-1
Example-2
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void submit(object sender, EventArgs e)
{
Literal1.Text = "What is the use of this control";
}
}
Thanks
Anuja PawarRank #1,404 · 1.2K reputationPosted Jan 9, 2012, 10:07 PM EST
@ 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="This is Devmanuals.com" runat="server" /> br /> br /> Pass Through Mode: br /> asp:Literal ID="literal2" Mode="PassThrough" Text="This is Devmanuals.com" runat="server" /> br /> br /> Encode Mode: br /> asp:Literal ID="literal3" Mode="Encode" Text="This is Devmanuals.com" runat="server" /> div> asp:Content> br /> asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="#000099" /> asp:Content>