WebPart.Zone Property
Assembly: System.Web (in system.web.dll)
/** @property */ public WebPartZoneBase get_Zone ()
public function get Zone () : WebPartZoneBase
Not applicable.
Property Value
The WebPartZoneBase that currently contains a Web Parts control on a Web page. If a Web Parts control is currently closed on a page, the return value is a null reference (Nothing in Visual Basic).In the architecture of the Web Parts control set, controls can have Web Parts functionality only if they operate inside of WebPartZoneBase zones. The standard WebPartZoneBase zone to use on Web pages is the WebPartZone control. Although end users can move Web Parts controls between different zones on a Web page, a given instance of a control can reside in only one zone at a time. A Web Parts control, and its associated WebPartManager control, use the Zone property to keep track of which zone the control currently resides in, and what common layout and style characteristics of the zone apply to all contained Web Parts controls.
The following code example demonstrates how to access the Zone and ZoneIndex properties for a custom Web Parts control. This example assumes the use of a custom control, TextDisplayWebPart, created in the Example section of the WebPart class overview.
The code example includes a custom user control that enables users to change display modes on a Web Parts page. The user control is referenced by means of a Register directive near the top of the Web page that hosts the user control. For a detailed description of how to create this user control and work with display modes, see Walkthrough: Developing and Using a Custom Server Control.
The second part of the code example is the Web page. There are two <asp:webpartzone> elements on the page, each representing a Web Parts zone. The first zone contains a standard Calendar control, which acts like a WebPart control at run time because it is in a zone. The second zone contains the TextDisplayWebPart control. When a user clicks the Zone Information button, the Label1 control displays the values of the ZoneIndex property for the control, and the ID property of the zone that currently contains the control.
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.