ControlCollection Constructor
Initializes a new instance of the ControlCollection class for the parent server control specified in the owner parameter.
[Visual Basic] Public Sub New( _ ByVal owner As Control _ ) [C#] public ControlCollection( Control owner ); [C++] public: ControlCollection( Control* owner ); [JScript] public function ControlCollection( owner : Control );
Parameters
- owner
- The ASP.NET server control that the control collection is created for.
Exceptions
| Exception Type | Condition |
|---|---|
| ArgumentException | Occurs if the owner parameter is a null reference (Nothing in Visual Basic). |
Example
[Visual Basic] The following code example is a custom ControlCollection class that overrides the constructor to write messages, that includes the name of the Owner property, to the trace log when an instance of the collection is created. You must enable tracing for the page or application for this example to work.
[Visual Basic]
' Create a custom ControlCollection that writes
' information to the Trace log when an instance
' of the collection is created.
Public Class CustomControlCollection
Inherits ControlCollection
Private context As HttpContext
Public Sub New(ByVal owner As Control)
MyBase.New(owner)
context.Trace.Write("The control collection is created.")
' The displays the Name of the control
' that uses this collection when tracing is enabled.
context.Trace.Write("The owner is: " _
& Me.Owner.ToString())
End Sub
End Class
[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
ControlCollection Class | ControlCollection Members | System.Web.UI Namespace | Controls | Control