다음을 통해 공유


ControlCollection.Owner 속성

정의

개체가 속한 ASP.NET 서버 컨트롤을 ControlCollection 가져옵니다.

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

속성 값

Control 속해 있는 ControlCollection 값입니다.

예제

다음 코드 예제는 컬렉션의 인스턴스를 만들 때 추적 로그에 메시지를 쓰는 메서드를 재정 ControlCollectionOwner 하는 사용자 지정 ControlCollection 클래스입니다(속성 이름 포함). 이 예제가 작동하려면 페이지 또는 애플리케이션에 대한 추적을 사용하도록 설정해야 합니다.

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

적용 대상

추가 정보