Skip to main content
.NET Framework Class Library
ControlIsLiteralContent Method

This API 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)
Syntax
Protected Function IsLiteralContent As [%$TOPIC/c5zkx4x3_en-us_VS_110_1_0_0_0_0%]
protected [%$TOPIC/c5zkx4x3_en-us_VS_110_1_0_1_0_0%] IsLiteralContent()
protected:
[%$TOPIC/c5zkx4x3_en-us_VS_110_1_0_2_0_0%] IsLiteralContent()
member IsLiteralContent : unit -> [%$TOPIC/c5zkx4x3_en-us_VS_110_1_0_3_0_0%]

Return Value

Type: SystemBoolean
true if the server control contains solely literal content; otherwise false.
Remarks

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

Examples

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. 
Overrides Protected Sub OnLoad(ByVal e As EventArgs)

   If Page.IsPostBack = True Then 
      Dim s As String 

      If Me.IsLiteralContent() = True Then
         s = Controls(0).UniqueID
         Context.Response.Write(s)
      Else
         Context.Response.Write( _
         "The control contains more than literal content.")
      End If 
   End If 
End Sub
// 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;
                        Context.Response.Write(s);
                }
                else
                {
                        Context.Response.Write(
                                "The control contains more than literal content.");
                }
        }
}
Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0
Platforms

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.