EmptyControlCollection Class
.NET Framework 4.5
Provides standard support for a ControlCollection collection that is always empty.
Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
The EmptyControlCollection type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | EmptyControlCollection | Initializes a new instance of the EmptyControlCollection class. |
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of server controls in the ControlCollection object for the specified ASP.NET server control. (Inherited from ControlCollection.) |
![]() | IsReadOnly | Gets a value indicating whether the ControlCollection object is read-only. (Inherited from ControlCollection.) |
![]() | IsSynchronized | Gets a value indicating whether the ControlCollection object is synchronized. (Inherited from ControlCollection.) |
![]() | Item | Gets a reference to the server control at the specified index location in the ControlCollection object. (Inherited from ControlCollection.) |
![]() | Owner | Gets the ASP.NET server control to which the ControlCollection object belongs. (Inherited from ControlCollection.) |
![]() | SyncRoot | Gets an object that can be used to synchronize access to the collection of controls. (Inherited from ControlCollection.) |
| Name | Description | |
|---|---|---|
![]() | Add | Denies the addition of the specified Control object to the collection. (Overrides ControlCollection.Add(Control).) |
![]() | AddAt | Denies the addition of the specified Control object to the collection, at the specified index position. (Overrides ControlCollection.AddAt(Int32, Control).) |
![]() | Clear | Removes all controls from the current server control's ControlCollection object. (Inherited from ControlCollection.) |
![]() | Contains | Determines whether the specified server control is in the parent server control's ControlCollection object. (Inherited from ControlCollection.) |
![]() | CopyTo | Copies the child controls stored in the ControlCollection object to an System.Array object, beginning at the specified index location in the System.Array. (Inherited from ControlCollection.) |
![]() | Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetEnumerator | Retrieves an enumerator that can iterate through the ControlCollection object. (Inherited from ControlCollection.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IndexOf | Retrieves the index of a specified Control object in the collection. (Inherited from ControlCollection.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | Remove | Removes the specified server control from the parent server control's ControlCollection object. (Inherited from ControlCollection.) |
![]() | RemoveAt | Removes a child control, at the specified index location, from the ControlCollection object. (Inherited from ControlCollection.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
/* File name: emptyControlCollection.cs. */ using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; namespace CustomControls { // Defines a simple custom control. public class MyCS_EmptyControl : Control { [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] protected override ControlCollection CreateControlCollection() /* * Function Name: CreateControlCollection. * Denies the creation of any child control by creating an empty collection. * Generates an exception if an attempt to create a child control is made. */ { return new EmptyControlCollection(this); } [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] protected override void CreateChildControls() /* * Function Name: CreateChildControls. * Populates the child control collection (Controls). * Note: This function will cause an exception because the control does not allow * child controls. */ { // Create a literal control to contain the header and add it to the collection. LiteralControl text; text = new LiteralControl("<h5>Composite Controls</h5>"); Controls.Add(text); } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
