Freigeben über


Control.IsLiteralContent-Methode

Diese Methode unterstützt die .NET Framework-Infrastruktur und ist nicht für die direkte Verwendung in Code bestimmt.

Ermittelt, ob das Serversteuerelement nur literalen Inhalt enthält.

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

Syntax

'Declaration
Protected Function IsLiteralContent As Boolean
'Usage
Dim returnValue As Boolean

returnValue = Me.IsLiteralContent
protected bool IsLiteralContent ()
protected:
bool IsLiteralContent ()
protected boolean IsLiteralContent ()
protected function IsLiteralContent () : boolean

Rückgabewert

true, wenn das Serversteuerelement nur literalen Inhalt enthält, andernfalls false.

Hinweise

Wenn diese Methode true zurückgibt, enthält die Auflistung des Serversteuerelements nur ein einziges literales Steuerelement.

Beispiel

Im folgenden Beispiel wird überprüft, ob die Seite mit den Serversteuerelementen zurückgesendet wurde. Wenn dies der Fall ist, wird die IsLiteralContent-Methode aufgerufen, um zu bestimmen, ob das Steuerelement nur literalen Inhalt enthält oder anderen Serversteuerelementen übergeordnet ist. Wenn es nur literalen Inhalt enthält, wird die UniqueID-Eigenschaft des LiteralControl in die Antwort geschrieben, das den Inhalt darstellt.

' 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.");
                }
        }
}

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Control-Klasse
Control-Member
System.Web.UI-Namespace
HasControls
LiteralControl