다음을 통해 공유


ControlCollection(Control) 생성자

정의

지정된 부모 서버 컨트롤에 대한 클래스의 ControlCollection 새 인스턴스를 초기화합니다.

public:
 ControlCollection(System::Web::UI::Control ^ owner);
public ControlCollection(System.Web.UI.Control owner);
new System.Web.UI.ControlCollection : System.Web.UI.Control -> System.Web.UI.ControlCollection
Public Sub New (owner As Control)

매개 변수

owner
Control

컨트롤 컬렉션이 만들어지는 ASP.NET 서버 컨트롤입니다.

예외

매개 변수null가 .인 owner 경우 발생합니다.

예제

다음 코드 예제는 컬렉션의 인스턴스를 만들 때 추적 로그에 메시지(속성 이름 Owner 포함)를 쓰도록 생성자를 재정의하는 사용자 지정 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

적용 대상

추가 정보