Control.IsLiteralContent Metoda

Definicja

Określa, czy kontrolka serwera zawiera tylko zawartość literału.

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

Zwraca

true jeśli kontrolka serwera zawiera wyłącznie zawartość literału; w przeciwnym razie false.

Przykłady

Poniższy przykład sprawdza, czy strona zawierająca kontrolki serwera została wysłana wstecz. Jeśli tak, wywołuje metodę IsLiteralContent w celu określenia, czy kontrolka zawiera tylko zawartość literału, czy też jest kontrolką nadrzędną do innych kontrolek serwera. Jeśli zawiera wyłącznie zawartość literału, UniqueID właściwość LiteralControl , która reprezentuje zawartość, jest zapisywana w odpowiedzi.

// 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

Uwagi

Gdy ta metoda zwróci truemetodę , kolekcja kontrolki serwera zawiera pojedynczą kontrolkę literału.

Dotyczy

Zobacz też