Metodo Control.IsLiteralContent (System.Web.UI)

Cambia visualizzazione:
ScriptFree
Riferimento a .NET Framework
Metodo Control.IsLiteralContent
Il presente articolo è stato tradotto manualmente. Per visualizzare questa pagina e contemporaneamente visualizzarne il contenuto in lingua inglese, passare alla visualizzazione semplificata.

Questa API supporta l'infrastruttura .NET Framework e non deve essere utilizzata direttamente dal codice.

Determina se il controllo server conserva solo il contenuto literal.

Spazio dei nomi:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)
Sintassi

Visual Basic
Protected Function IsLiteralContent As Boolean
C#
protected bool IsLiteralContent()
Visual C++
protected:
bool IsLiteralContent()
F#
member IsLiteralContent : unit -> bool 

Valore restituito

Tipo: System.Boolean
true se il controllo server contiene solo il contenuto literal; in caso contrario false.
Note

Quando questo metodo restituisce true, l'insieme del controllo server conserva un unico controllo.

Esempi

Nell'esempio riportato di seguito viene verificato se la pagina contenente i controlli server è stata restituita. In caso affermativo, viene chiamato il metodo IsLiteralContent per determinare se il controllo contiene solo contenuto effettivo o se si tratta di un controllo padre di altri controlli server. Se contiene solo contenuto effettivo, la proprietà UniqueID dell'oggetto LiteralControl che rappresenta quel contenuto viene scritta nella risposta.

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(s)
      Else
         Context.Response.Write( _
         "The control contains more than literal content.")
      End If
   End If
End Sub


C#

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


Informazioni sulla versione

.NET Framework

Supportato in: 4, 3.5, 3.0, 2.0, 1.1, 1.0
Piattaforme

Windows 7, Windows Vista SP1 o versione successiva, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (componenti di base del server non supportati), Windows Server 2008 R2 (componenti di base del server supportati con SP1 o versione successiva), Windows Server 2003 SP2

.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.
Vedere anche

Riferimenti