WebPart::ZoneIndex Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the index position of a WebPart control within its zone.

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

property int ZoneIndex {
	int get();

Property Value

Type: System::Int32

The numerical order of a control within its zone. The first control in a zone has an index value of zero.

The ZoneIndex property indicates a Web Parts control's numerical order (or ordinal position) within its zone, relative to other controls in the zone. The WebPartManager control uses this property to track and manage its collection of Web Parts controls on a Web page.


You cannot assume that the value of the ZoneIndex property for a control will equal the index value for the same control within the WebParts collection of the control's zone. Often a control's relative position in its zone (its ZoneIndex value), and its index within the WebParts collection of its zone, will be different values as controls are added to and removed from zones.

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.

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

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.

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

.NET Framework
Available since 2.0
Return to top