DisplayModes Property

WebPartManager.DisplayModes Property


Gets a read-only collection of all display modes that are associated with a WebPartManager control.

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

public WebPartDisplayModeCollection DisplayModes { get; }

Property Value

Type: System.Web.UI.WebControls.WebParts.WebPartDisplayModeCollection

A WebPartDisplayModeCollection that contains the set of WebPartDisplayMode objects associated with the WebPartManager control.

The DisplayModes property references all associated display modes, in contrast with the SupportedDisplayModes property, which references only the display modes that are available (supported) on the current page.

Two of the provided display modes, browse and design, are always supported on a page. The other three display modes, edit, catalog, and connections, are supported only when a page has the corresponding type of zone necessary for a particular display mode to work. For example, if you page does not contain an EditorZone zone, the edit display mode would appear in the collection referenced by the DisplayModes property, but would not appear in the collection referenced by the SupportedDisplayModes property.

Legacy Code Example

The following code example shows the programmatic use of the DisplayModes property. The code uses this property to populate the list with all the display modes available in the Web Parts control set, even those that are not supported on the current page. In this case, the catalog and connect display modes are not supported, because their corresponding required zones are not on the page.

The other three display modes--browse, design, and edit--are supported on the page. Edit mode is supported because the page contains an EditorZone zone, while browse and design modes are always supported.

After you load the page in a browser, you can use the drop-down list control to switch the page from browse mode to design mode, and then to edit mode. In edit mode, you can click the drop-down verbs menu in the header of one of the server controls, and select Edit to edit the control. Note that if you select Catalog or Connect in the drop-down list, an error page is generated.

Code snippet is not found. Confirm that the code snippet name 'WebParts_WebPartManager_DisplayModes' is correct.

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft