Export (0) Print
Expand All

WebPart::ZoneIndex Property

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.

Important noteImportant

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

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft