EmptyControlCollection Class
TOC
Collapse the table of content
Expand the table of content

EmptyControlCollection Class

 

Provides standard support for a ControlCollection collection that is always empty.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

System.Object
  System.Web.UI.ControlCollection
    System.Web.UI.EmptyControlCollection

public class EmptyControlCollection : ControlCollection

NameDescription
System_CAPS_pubmethodEmptyControlCollection(Control)

Initializes a new instance of the EmptyControlCollection class.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of server controls in the ControlCollection object for the specified ASP.NET server control.(Inherited from ControlCollection.)

System_CAPS_pubpropertyIsReadOnly

Gets a value indicating whether the ControlCollection object is read-only.(Inherited from ControlCollection.)

System_CAPS_pubpropertyIsSynchronized

Gets a value indicating whether the ControlCollection object is synchronized.(Inherited from ControlCollection.)

System_CAPS_pubpropertyItem[Int32]

Gets a reference to the server control at the specified index location in the ControlCollection object.(Inherited from ControlCollection.)

System_CAPS_protpropertyOwner

Gets the ASP.NET server control to which the ControlCollection object belongs.(Inherited from ControlCollection.)

System_CAPS_pubpropertySyncRoot

Gets an object that can be used to synchronize access to the collection of controls.(Inherited from ControlCollection.)

NameDescription
System_CAPS_pubmethodAdd(Control)

Denies the addition of the specified Control object to the collection.(Overrides ControlCollection.Add(Control).)

System_CAPS_pubmethodAddAt(Int32, Control)

Denies the addition of the specified Control object to the collection, at the specified index position.(Overrides ControlCollection.AddAt(Int32, Control).)

System_CAPS_pubmethodClear()

Removes all controls from the current server control's ControlCollection object.(Inherited from ControlCollection.)

System_CAPS_pubmethodContains(Control)

Determines whether the specified server control is in the parent server control's ControlCollection object.(Inherited from ControlCollection.)

System_CAPS_pubmethodCopyTo(Array, Int32)

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.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Retrieves an enumerator that can iterate through the ControlCollection object.(Inherited from ControlCollection.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIndexOf(Control)

Retrieves the index of a specified Control object in the collection.(Inherited from ControlCollection.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodRemove(Control)

Removes the specified server control from the parent server control's ControlCollection object.(Inherited from ControlCollection.)

System_CAPS_pubmethodRemoveAt(Int32)

Removes a child control, at the specified index location, from the ControlCollection object.(Inherited from ControlCollection.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

This class is used when you want to define a custom control that does not allow child controls.


/* 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);
      }
   }

}

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft