Control.IsLiteralContent Method

This method supports the .NET Framework infrastructure and is not intended to be used directly from your code.
Determines if the server control holds only literal content.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

protected bool IsLiteralContent ()
protected boolean IsLiteralContent ()
protected function IsLiteralContent () : boolean
Not applicable.

Return Value

true if the server control contains solely literal content; otherwise false.

When this method returns true, the server control's collection holds a single literal control.

The following example checks whether the page that contains the server controls has posted back. If it has, it calls the IsLiteralContent method to determine whether the control contains just literal content, or is a parent control to other server controls. If it contains solely literal content, the UniqueID property of the LiteralControl that represents that content is written to the response.

// Override the OnLoad method to check if the 
// page that uses this control has posted back.
// If so, check whether this controls contains
// only literal content, and if it does,
// it gets the UniqueID property and writes it
// to the page. Otherwise, it writes a message
// that the control contains more than literal content.
protected override void OnLoad(EventArgs e)
        if (Page.IsPostBack)
                String s;

                if (this.IsLiteralContent())
                        s = Controls[0].UniqueID;
                                "The control contains more than literal content.");

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0