This documentation is archived and is not being maintained.

EditorPart Class

Serves as the base class for controls that reside in EditorZoneBase zones and are used to edit WebPart controls.

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

[BindableAttribute(false)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class EditorPart abstract : public Part
<asp:EditorPart />

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.

NoteNote:

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

AppearanceEditorPart

Edits the appearance of the associated control, including properties such as its title text, height, width, and border attributes.

BehaviorEditorPart

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.

LayoutEditorPart

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.

PropertyGridEditorPart

Edits properties of the associated control, if those properties were declared in the source code with a WebBrowsable attribute.

NoteNote:

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).

Notes to Inheritors:

To create a custom EditorPart control, you must override two important methods. The ApplyChanges method applies changes made in the editor control to the WebPart control being edited. The SyncChanges method gets the current values of the WebPart control being edited, so that the editor control can edit them. Using these two critical methods, you get and set values between your custom EditorPart control and the WebPart control it is editing.

If you derive from the EditorPart class to create custom editor controls, you can add your custom controls to an EditorZoneBase zone by implementing the IWebEditable interface in a WebPart control, a user control, or a server control. For more details and a code example, see the IWebEditable class overview. Also, the code example in the Example section demonstrates how to implement IWebEditable in a custom WebPart control.

TopicLocation
How to: Set the Display Mode of a Web Parts PageBuilding ASP .NET Web Applications
How to: Set the Display Mode of a Web Parts PageBuilding 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.

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

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.

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

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.

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

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.

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 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.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: