WebPartDisplayMode Class

Defines a common set of properties for the several display modes that a Web Parts page can enter.

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

public ref class WebPartDisplayMode abstract
public abstract class WebPartDisplayMode
public abstract class WebPartDisplayMode
Not applicable.

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

BrowseDisplayMode

Displays Web Parts controls and UI elements in the normal mode in which end users view a page.

DesignDisplayMode

Displays zone UI elements and enables users to drag Web Parts controls to change the layout of a page.

EditDisplayMode

Displays special editing UI elements and enables end users to edit the controls on a page.

CatalogDisplayMode

Displays special catalog UI elements and enables end users to add and remove page controls.

ConnectDisplayMode

Displays special connections UI elements and enables end users to connect Web Parts controls.

Notes to Inheritors: 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 Server Control.

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

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.

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

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.

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

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.

  • AspNetHostingPermission  for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
  • AspNetHostingPermission  for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.

System.Object
  System.Web.UI.WebControls.WebParts.WebPartDisplayMode

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Show: