WebPartManager.Zones Property
Assembly: System.Web (in system.web.dll)
/** @property */ public WebPartZoneCollection get_Zones ()
public function get Zones () : WebPartZoneCollection
Not applicable.
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.
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 Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.