EditorPart Class
Assembly: System.Web (in system.web.dll)
The EditorPart class provides a base set of properties and methods that are used by the derived EditorPart controls provided with the Web Parts control set, and by custom EditorPart controls. An EditorPart control allows a user to edit an associated WebPart control by modifying its layout, appearance, properties, behavior, or other characteristics.
The editing user interface (UI), which consists of EditorZoneBase zones that contain EditorPart controls, is displayed after a Web page enters edit mode.
Note: |
|---|
| An EditorPart control can be used only within a zone that derives from the EditorZoneBase class, such as the EditorZone control. |
After a page has entered edit mode, a user can select a WebPart control to edit by clicking an edit verb on the verbs menu of the selected control. Only one WebPart control can be edited at a time.
Several derived EditorPart controls are provided with the Web Parts control set, as listed in the following table. These controls provide all the editing capabilities that are necessary for most applications. The typical approach for using these controls in a Web Parts page is to declare them in page persistence format within a <zonetemplate> element, where <zonetemplate> is the child element of an <asp:editorzone> element. For a code example, see the Example section of this topic.
| Type of control | Description |
|---|---|
| Edits the appearance of the associated control, including properties such as its title text, height, width, and border attributes. | |
| Edits certain behaviors of the associated control, such as whether it can be edited, whether it can be closed, or whether it can be moved to another zone. This control is only visible on a page when a control is being edited in shared personalization scope. | |
| Edits layout attributes for the associated control, such as whether it is in a normal or minimized (collapsed) state, and what zone it is placed in. | |
| Edits properties of the associated control, if those properties were declared in the source code with a WebBrowsable attribute. |
Note: |
|---|
| To improve accessibility, all the EditorPart controls provided in the Web Parts control set are rendered within a <fieldset> element. The <fieldset> element groups the related set of controls used for editing in a given EditorPart control, and it facilitates tabbed navigation among those controls for both visual user agents (such as ordinary Web browsers) and speech-oriented user agents (such as screen-reading software). |
| 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 declarative and programmatic use of EditorPart controls. This code example has four parts:
-
A user control that enables you to change display modes on a Web Parts page.
-
A Web page that contains an EditorZone control, with several of the EditorPart controls from the Web Parts control set declared in the zone, and a reference to a custom WebPart control.
-
A class that contains the custom WebPart control, and a custom EditorPart control for editing a property in the WebPart control.
-
An explanation of how the example works when you load the page in a browser.
The first part of this code example is the user control that enables users to change display modes on a Web page. For details about display modes and a description of the source code in this control, see Walkthrough: Changing Display Modes on a Web Parts Page.
The second part of the code example is the Web page. It contains a declarative reference to an EditorZone control, with a child <zonetemplate> element that contains declarative references to two of the Web Parts control set EditorPart controls. The page also references a custom WebPart control, using a Register directive for the assembly, and the <aspSample:TextDisplayWebPart> element for the control.
The third part of the code example is a custom WebPart class named TextDisplayWebPart. The class implements the IWebEditable interface. Within this class is a nested, private class that contains the code for a private EditorPart class associated with the TextDisplayWebPart class and named TextDisplayEditorPart. At run time, as the TextDisplayWebPart control enters edit mode, in its TextDisplayWebPart.CreateEditorParts method, it creates an instance of the TextDisplayEditorPart class, and displays it in the EditorZone control, along with the other EditorPart controls.
Load the page in a browser, and on the Display Mode control, select Edit Mode to switch to edit mode. Click the verbs menu (the downward arrow) in the title bar of the TextDisplayWebPart control, and click Edit to edit the control. When the editing UI is visible, you can see three EditorPart controls, including the custom one that enables you to edit the TextDisplayWebPart.FontStyle property. If you make some changes in the editing UI and click the Apply button, you can use the drop-down list control to return the page to browse mode and see the full effect of the editing changes.
- 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.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.Panel
System.Web.UI.WebControls.WebParts.Part
System.Web.UI.WebControls.WebParts.EditorPart
System.Web.UI.WebControls.WebParts.AppearanceEditorPart
System.Web.UI.WebControls.WebParts.BehaviorEditorPart
System.Web.UI.WebControls.WebParts.LayoutEditorPart
System.Web.UI.WebControls.WebParts.PropertyGridEditorPart
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.
Note: