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 서버 컨트롤입니다.

예외

owner 매개 변수가 null이면 발생하는 경우

예제

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

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

적용 대상

추가 정보