WebPart::AllowZoneChange Property

 

Gets or sets a value indicating whether a user can move a WebPart control between WebPartZoneBase zones.

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

public:
[PersonalizableAttribute(PersonalizationScope::Shared)]
[ThemeableAttribute(false)]
property bool AllowZoneChange {
	virtual bool get();
	virtual void set(bool value);
}

Property Value

Type: System::Boolean

true if the WebPart control can move between zones; otherwise, false. The default value is true.

When the AllowZoneChange property is true, and a Web page is in a display mode that allows layout changes (such as edit or design mode), a user can change the page layout by moving a control to another WebPartZoneBase zone on the page. If the property is set to false, a control cannot be moved between zones, but can still be moved within its current zone.

This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins.

The personalization scope of this property is set to Shared and can be modified only by authorized users. For more information, see PersonalizableAttribute and Web Parts Personalization Overview.

The following code example demonstrates how to change the default setting of the AllowZoneChange property for a custom Web Parts control, so that an end user cannot move the control to a different zone. This example assumes the use of a custom control, TextDisplayWebPart, which is found in the Example section of the WebPart class overview.

The code example also uses 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.

In the declarative markup for the Web Page, on the second <aspSample:TextDisplayWebPart> element, note the AllowZoneChange="false" attribute. At run time, an end user could drag the first control into WebPartZone2, but could not do the same with the second control. Load the page in a browser and use the Display Mode drop-down list control to change the display mode to design mode. Try to drag each of the WebPart controls into another zone, and note the different behavior based on the values of their AllowZoneChange properties.

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

.NET Framework
Available since 2.0
Return to top
Show: