WebPart::Zone Property
Gets the WebPartZoneBase zone that currently contains a WebPart control.
Assembly: System.Web (in System.Web.dll)
[BrowsableAttribute(false)] public: property WebPartZoneBase^ Zone { WebPartZoneBase^ get (); }
Property Value
Type: System.Web.UI.WebControls.WebParts::WebPartZoneBaseThe 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 nullptr.
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 Web 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 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.