Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

WebPartZoneCollection Constructor (ICollection)

Note: This constructor is new in the .NET Framework version 2.0.

Initializes an instance of the WebPartZoneCollection class by passing in a collection of WebPartZone objects.

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

public WebPartZoneCollection (
	ICollection webPartZones
public WebPartZoneCollection (
	ICollection webPartZones
public function WebPartZoneCollection (
	webPartZones : ICollection



An ICollection of WebPartZone objects.

Exception typeCondition


The collection of zones is a null reference (Nothing in Visual Basic).

Use the WebPartZoneCollection constructor when you want to create a custom collection of WebPartZone objects to carry out programmatic operations on them. For example, you could access the Zones property and create a subset of WebPartZone objects on a Web Parts page, assigning them to a WebPartZoneCollection object, and then carry out operations on the child controls or various properties of only that subset of zones.

The following code example demonstrates the use of the WebPartZoneCollection constructor. The complete code for the example is found in the Example section of the WebPartZoneCollection class overview.

In the following section of code, notice that it assigns a WebPartZoneCollection object to a variable by retrieving the value of the Zones property. If you wanted, rather than assigning all the zones from the Zones property, you could create an array of WebPartZoneBase objects containing a subset of all the zones on the page, and assign the array to a new WebPartZoneCollection object.

protected void Button5_Click(object sender, EventArgs e)
  Label1.Text = String.Empty;

  WebPartZoneCollection zoneCollection = mgr.Zones;
  foreach (WebPartZone zone in zoneCollection)

    if (zone.WebPartVerbRenderMode == WebPartVerbRenderMode.Menu)
      zone.WebPartVerbRenderMode = WebPartVerbRenderMode.TitleBar;
      zone.WebPartVerbRenderMode = WebPartVerbRenderMode.Menu;

After the collection is created, you can easily iterate through the collection and perform operations on all the contained zones or their contents. To execute the example code, load the page in a browser, and click the Toggle Verb Render Mode button on each zone. This alternates how the verbs in the title bar of each server control contained in a zone are rendered. The verbs can appear in a drop-down menu, or directly as links in the title bar.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.