WebPartManager::DisplayMode Property
Gets or sets the active display mode for a Web page that contains Web Parts controls.
Assembly: System.Web (in System.Web.dll)
[BrowsableAttribute(false)] public: virtual property WebPartDisplayMode^ DisplayMode { WebPartDisplayMode^ get (); void set (WebPartDisplayMode^ value); }
<asp:WebPartManager DisplayMode="WebPartDisplayMode" />
Property Value
Type: System.Web.UI.WebControls.WebParts::WebPartDisplayModeA WebPartDisplayMode that determines a page's display mode.
| Exception | Condition |
|---|---|
| ArgumentNullException | The WebPartDisplayMode object being assigned to the property is nullptr. |
| ArgumentException | The WebPartDisplayMode object being assigned to the property is not one of the supported display modes. - or - The WebPartDisplayMode object being assigned to the property is disabled. |
A page that contains Web Parts controls is always in one of several possible display modes. For details about display modes, see Web Parts Page Display Modes.
The WebPartManager class creates the display modes for a Web page. Using the base WebPartDisplayMode class, the WebPartManager control creates several standard display mode objects that can be used on pages that contain Web Parts controls. These standard display modes are described in the WebPartDisplayMode class overview.
The WebPartManager control also manages the display modes for pages that use Web Parts controls. Using the DisplayMode property, the WebPartManager control keeps a reference to the current display mode on a page. You can also use the DisplayMode property to switch a page into different display modes. For an example of changing display modes on a page that uses Web Parts controls, see Walkthrough: Changing Display Modes on a Web Parts Page.
As part of managing the display mode, the WebPartManager control also provides events and event handlers relating to display modes, such as the OnDisplayModeChanged method and the OnDisplayModeChanging method. These methods provide a mechanism for customizing a page's behavior, and even for adding a custom display mode.
| Topic | Location |
|---|---|
| How to: Set the Display Mode of a Web Parts Page | Building ASP .NET Web Applications |
| How to: Set the Display Mode of a Web Parts Page | Building ASP .NET Web Applications |
The following code example demonstrates programmatic use of the DisplayMode property. After loading the page in a browser, you can use the buttons near the bottom of the page to switch display modes. The page is in browse mode by default when it loads. If you switch to design mode, you can drag the server controls from one zone to another, or arrange two controls within one zone. If you switch to edit mode, you can click the verbs menu in the header of either of the server controls, select Edit, and edit the control using the provided editing user interface (UI).
Note: |
|---|
Switching among display modes in a Web Parts application is very common, and you might want to provide a consistent, reusable way to do this on all your pages that contain Web Parts controls. For an example of a user control that changes display modes and that can be reused on many pages, see Walkthrough: Changing Display Modes on a Web Parts Page. |
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: