WebPartZoneCollection Class
Contains a read-only collection of WebPartZone controls.
System.Collections::ReadOnlyCollectionBase
System.Web.UI.WebControls.WebParts::WebPartZoneCollection
Assembly: System.Web (in System.Web.dll)
The WebPartZoneCollection type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | WebPartZoneCollection() | Initializes an empty instance of the WebPartZoneCollection class. |
![]() | WebPartZoneCollection(ICollection) | Initializes an instance of the WebPartZoneCollection class by passing in a collection of WebPartZone objects. |
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of elements contained in the ReadOnlyCollectionBase instance. (Inherited from ReadOnlyCollectionBase.) |
![]() | InnerList | Gets the list of elements contained in the ReadOnlyCollectionBase instance. (Inherited from ReadOnlyCollectionBase.) |
![]() | Item[Int32] | Returns a specific member of the collection by passing in an integer. |
![]() | Item[String] | Returns a specific member of the collection by passing in a unique identifier. |
| Name | Description | |
|---|---|---|
![]() | Contains | Returns a value indicating whether a particular zone exists in the collection. |
![]() | CopyTo | Copies the collection to an array of WebPartZoneBase objects. |
![]() | 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 | Returns an enumerator that iterates through the ReadOnlyCollectionBase instance. (Inherited from ReadOnlyCollectionBase.) |
![]() | 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 | Returns the position of a particular member of the collection. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | ICollection::CopyTo | Copies the entire ReadOnlyCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from ReadOnlyCollectionBase.) |
![]() ![]() | ICollection::IsSynchronized | Gets a value indicating whether access to a ReadOnlyCollectionBase object is synchronized (thread safe). (Inherited from ReadOnlyCollectionBase.) |
![]() ![]() | ICollection::SyncRoot | Gets an object that can be used to synchronize access to a ReadOnlyCollectionBase object. (Inherited from ReadOnlyCollectionBase.) |
The WebPartZoneCollection class contains the collection of WebPartZone controls that exist on a Web Parts page. It is used primarily by the WebPartManager control to track and manage all the zones. The WebPartManager control keeps a reference to the collection of zones on a page in its read-only Zones property.
The WebPartZoneCollection class is useful when you want to carry out operations on multiple zones or their contents at the same time, or when you need to locate a particular zone and examine or change its contents. Although the collection of zones itself is read-only and you cannot change the size of the collection object itself, you can still get references to the individual zones within the collection, and when you have a reference to an individual zone object, you can change its property values.
The WebPartZoneCollection class has two constructors. The first one, WebPartZoneCollection(), simply initializes an empty instance of a new WebPartZoneCollection. The second one, WebPartZoneCollection(ICollection), initializes a collection by passing in an existing collection of zones.
The WebPartZoneCollection class contains an Item property. This property allows you to locate a WebPartZone control within the collection by passing in a string identifier. The zone is located by matching the string identifier to the value of the ID property on a WebPartZoneBase zone.
The WebPartZoneCollection class also has several methods that are useful for examining or accessing its contents. The Contains method determines whether a particular zone exists in the collection. The CopyTo method copies the collection to an array of WebPartZoneBase objects. Finally, the IndexOf method returns the index of a particular zone within the collection.
The following code example demonstrates the use of the WebPartZoneCollection class. The code example contains three parts: two sections of code, and an explanation of how to run the example.
The first part of the code example is a Web page that contains three WebPartZone controls, each of which contains a single server control. Although these server controls are all standard ASP.NET controls, they can act as WebPart controls at run time because they are placed within a WebPartZone zone.
The second part of the code example is the partial class that contains the code to demonstrate usage of the WebPartZoneCollection class. This code handles the events for the Web page.
Load the page in a browser. The three WebPartZone zones are visible with their contained server controls. Near the bottom of the page are several buttons, each of which demonstrates some aspect of working with the WebPartZoneCollection object. Click each button to see its effect on the zones and their contents. To view the code associated with each button that demonstrates some aspect of the WebPartZoneCollection object, view the code in the partial class file referenced above as the second part of this code example.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.






