This documentation is archived and is not being maintained.

Control.IsLiteralContent Method

Determines if the server control holds only literal content.

[Visual Basic]
Protected Function IsLiteralContent() As Boolean
protected bool IsLiteralContent();
protected: bool IsLiteralContent();
protected function IsLiteralContent() : Boolean;

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.


[Visual Basic] 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 conent, or is a parent control to other server controls. If it contains solely literal content, the System.Web.UI.Control.UniqueId property of the LiteralControl that represents that content is written to the response.

[Visual Basic] 
' 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( _
         "The control contains more than literal content.")
      End If
   End If
End Sub

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Control Class | Control Members | System.Web.UI Namespace | HasControls | LiteralControl