WebPartDisplayMode Class
Defines a common set of properties for the several display modes that a Web Parts page can enter.
Assembly: System.Web (in System.Web.dll)
The WebPartDisplayMode type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | AllowPageDesign | Gets a value that determines whether users can change the layout of a Web Parts page when the page is in a certain display mode. |
![]() | AssociatedWithToolZone | Gets a value that indicates whether a certain display mode is associated with a class that derives from the ToolZone class. |
![]() | Name | Gets the name of a display mode. |
![]() | RequiresPersonalization | Gets a value that indicates whether a particular display mode requires personalization to be enabled. |
![]() | ShowHiddenWebParts | Gets a value that indicates whether controls that have their Hidden property set to true should be displayed. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IsEnabled | Gets a value that indicates whether users can personalize a page while the page is in a certain display mode. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
A Web Parts page can enter several different display modes. In each display mode, certain elements of the Web Parts user interface (UI) are either hidden or displayed, and certain kinds of user modifications to a page are either enabled or disabled. The WebPartManager control contains the implementation for the display modes that are available in the Web Parts control set, and manages the display modes for a page.
The following table lists fields that represent the available display modes.
Display mode | Description |
|---|---|
Displays Web Parts controls and UI elements in the normal mode in which end users view a page. | |
Displays zone UI elements and enables users to drag Web Parts controls to change the layout of a page. | |
Displays special editing UI elements and enables end users to edit the controls on a page. | |
Displays special catalog UI elements and enables end users to add and remove page controls. | |
Displays special connections UI elements and enables end users to connect Web Parts controls. |
Developers can derive from the WebPartDisplayMode class to create custom display modes. To make a custom WebPartDisplayMode available on a Web Parts page, you would also need to derive from the WebPartManager class, and override its CreateDisplayModes method.
The following code examples demonstrate the declarative use of display modes on a Web Parts page. Each of these display modes, as implemented by the Web Parts control set, is derived from the WebPartDisplayMode class.
This code example has four parts:
A custom WebPart control.
A Web page with a zone to host the custom control.
A user control that enables users to change display modes on the Web page.
An explanation of how the page works in a browser.
The first part of the example is a custom WebPart control, TextDisplayWebPart. For the code example to run, you must compile this source code. You can compile it explicitly and put the resulting assembly in your Web site's Bin folder or the global assembly cache. Alternatively, you can put the source code in your site's App_Code folder, where it will be dynamically compiled at run time. For a demonstration of both methods of compiling, see Walkthrough: Developing and Using a Custom Web Server Control.
The second part of the code example is a Web page that references a standard ASP.NET Calendar control within an <asp:webpartzone> element, so that the control is wrapped with a GenericWebPart control and given basic Web Parts functionality at run time. The page also references the TextDisplayWebPart control within an <asp:catalogzone> element, which demonstrates the end user's ability to switch to catalog mode and add controls to the page. The page also includes an <asp:editorzone> element, which enables users to edit the controls contained in the <asp:webpartzone> when the page is in edit mode. Near the top of the page are a register directive for the custom control and another one for the user control.
The third part of the code example is a user control that enables users to switch display modes on a Web page. Save the source code for this control in a file named DisplayModeMenuCS.ascx or DisplayModeMenuVB.ascx (depending on which language you use for the code example), and put it in the same directory as the Web page. For more details about display modes and a description of the source code in this control, see the topic Walkthrough: Changing Display Modes on a Web Parts Page.
When you load the page in a browser, you can use the Display Mode drop-down list control to switch to different display modes. To edit controls, select Edit in the drop-down list control. To edit a specific control, expose its verbs menu by clicking the arrow in the control's title bar, and then clicking Edit in the verbs menu. When a control is in edit mode, the editing controls added to this page enable you to change the edited control's appearance and layout. When you are finished, select Browse in the Display Mode drop-down list control to return the page to a normal view. To add controls to the page, switch to catalog mode. Notice that you can either use the Display Mode drop-down list control, or click the button near the bottom of the page. The inline code for the Button1_Click method demonstrates how to change display modes programmatically. While you are in catalog mode, you can add the custom TextDisplayWebPart control to the page.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.


