Freigeben über


ControlCollection.Owner Eigenschaft

Definition

Ruft das ASP.NET Serversteuerelement ab, zu dem das ControlCollection Objekt gehört.

protected:
 property System::Web::UI::Control ^ Owner { System::Web::UI::Control ^ get(); };
protected System.Web.UI.Control Owner { get; }
member this.Owner : System.Web.UI.Control
Protected ReadOnly Property Owner As Control

Eigenschaftswert

Das Control , zu dem die ControlCollection Gehört.

Beispiele

Das folgende Codebeispiel ist eine benutzerdefinierte ControlCollection Klasse, die die ControlCollection Methode überschreibt, um Nachrichten (die den Namen der Owner Eigenschaft enthalten) in das Ablaufverfolgungsprotokoll zu schreiben, wenn eine Instanz der Auflistung erstellt wird. Sie müssen die Ablaufverfolgung für die Seite oder Anwendung aktivieren, damit dieses Beispiel funktioniert.

// Create a custom ControlCollection that writes
// information to the Trace log when an instance
// of the collection is created.
[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
public class CustomControlCollection : ControlCollection
{
    private HttpContext context;

    public CustomControlCollection(Control owner)
        : base(owner)
    {

        HttpContext.Current.Trace.Write("The control collection is created.");
        // Display the Name of the control
        // that uses this collection when tracing is enabled.
        HttpContext.Current.Trace.Write("The owner is: " + this.Owner.ToString());
    }
}
' Create a custom ControlCollection that writes
' information to the Trace log when an instance
' of the collection is created.
<AspNetHostingPermission(SecurityAction.Demand, _
   Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomControlCollection
    Inherits ControlCollection

    Private context As HttpContext

    Public Sub New(ByVal owner As Control)
        MyBase.New(owner)
        HttpContext.Current.Trace.Write("The control collection is created.")
        ' Display the Name of the control
        ' that uses this collection when tracing is enabled.
        HttpContext.Current.Trace.Write("The owner is: " _
      & Me.Owner.ToString())
    End Sub


End Class

Gilt für:

Weitere Informationen