This documentation is archived and is not being maintained.

WebPartZoneCollection Class

Contains a read-only collection of WebPartZone controls.

System::Object
  System.Collections::ReadOnlyCollectionBase
    System.Web.UI.WebControls.WebParts::WebPartZoneCollection

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

public ref class WebPartZoneCollection sealed : public ReadOnlyCollectionBase

The WebPartZoneCollection type exposes the following members.

  NameDescription
Public methodWebPartZoneCollection()Initializes an empty instance of the WebPartZoneCollection class.
Public methodWebPartZoneCollection(ICollection)Initializes an instance of the WebPartZoneCollection class by passing in a collection of WebPartZone objects.
Top

  NameDescription
Public propertyCountGets the number of elements contained in the ReadOnlyCollectionBase instance. (Inherited from ReadOnlyCollectionBase.)
Protected propertyInnerListGets the list of elements contained in the ReadOnlyCollectionBase instance. (Inherited from ReadOnlyCollectionBase.)
Public propertyItem[Int32]Returns a specific member of the collection by passing in an integer.
Public propertyItem[String]Returns a specific member of the collection by passing in a unique identifier.
Top

  NameDescription
Public methodContainsReturns a value indicating whether a particular zone exists in the collection.
Public methodCopyToCopies the collection to an array of WebPartZoneBase objects.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an enumerator that iterates through the ReadOnlyCollectionBase instance. (Inherited from ReadOnlyCollectionBase.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfReturns the position of a particular member of the collection.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection::CopyToCopies the entire ReadOnlyCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from ReadOnlyCollectionBase.)
Explicit interface implemetationPrivate propertyICollection::IsSynchronizedGets a value indicating whether access to a ReadOnlyCollectionBase object is synchronized (thread safe). (Inherited from ReadOnlyCollectionBase.)
Explicit interface implemetationPrivate propertyICollection::SyncRootGets an object that can be used to synchronize access to a ReadOnlyCollectionBase object. (Inherited from ReadOnlyCollectionBase.)
Top

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.

No code example is currently available or this language may not be supported.

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.

No code example is currently available or this language may not be supported.

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.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

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.

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