Sdílet prostřednictvím


Control.IsLiteralContent Metoda

Definice

Určuje, zda ovládací prvek serveru obsahuje pouze literálový obsah.

protected:
 bool IsLiteralContent();
protected bool IsLiteralContent();
member this.IsLiteralContent : unit -> bool
Protected Function IsLiteralContent () As Boolean

Návraty

true pokud ovládací prvek serveru obsahuje výhradně literálový obsah; jinak false.

Příklady

Následující příklad zkontroluje, zda stránka, která obsahuje ovládací prvky serveru publikoval zpět. Pokud ano, volá metodu IsLiteralContent k určení, zda ovládací prvek obsahuje pouze literálový obsah, nebo je nadřazený ovládací prvek jiným serverovým ovládacím prvkům. Pokud obsahuje výhradně literálový obsah, UniqueID vlastnost LiteralControl , která představuje tento obsah je zapsán do odpovědi.

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

Poznámky

Když tato metoda vrátí true, kolekce ovládacího prvku serveru obsahuje jeden literálový ovládací prvek.

Platí pro

Viz také