WebPartManager.Zones Property

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

Gets a reference to a collection of all the WebPartZoneBase zones on a Web page.

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

public:
property WebPartZoneCollection^ Zones {
	WebPartZoneCollection^ get ();
}
/** @property */
public WebPartZoneCollection get_Zones ()

public function get Zones () : WebPartZoneCollection

Property Value

A WebPartZoneCollection that references a set of WebPartZoneBase zones.

The Zones property is used by the WebPartManager control to track the WebPartZoneBase zones on a Web page. Note that the property does not reference all types of zones; it references only zones that derive from the WebPartZoneBase class, including WebPartZone zones.

Although the collection referenced by the property is read-only, you can use it to access the individual objects in the collection and work with them programmatically.

The following code example demonstrates how to use the Zones property programmatically to access individual WebPartZoneBase zone controls. Notice that in the declarative markup for the Web page, there are two <asp:webpartzone> elements, each containing a server control. In the <script> section of the page, the code uses the Zones property to access the individual zones, listing all the zone IDs and then changing the background color on the second zone.

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

Note that for the code example to work, you must add a setting in the Web.config file to enable exporting Web Parts description files. Ensure that you have a Web.config file in the same directory as the Web page for this code example. Within the <system.web> section, make sure there is a <webParts> element with an enableExport attribute set to true, as in the following markup.

<webParts enableExport="true">

...

</webParts>

After you load the page into a browser, if you click the List Zone IDs button, the code uses the Zones property to list the IDs of all zones in the collection. If you click the Change Zone BackColor button, the code changes the background color of the second zone.

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

Community Additions

ADD
Show: