Provides an interface for developers to specify custom editing controls that are associated with a WebPart control.
Assembly: System.Web (in System.Web.dll)
Thetype exposes the following members.
The interface enables you to associate custom EditorPart controls with a server control--such as a WebPart control, a user control, or a custom server control. The EditorPart controls are contained with an EditorZone control, and this zone with its editing controls provides end users with a user interface (UI) for modifying properties, appearance, and behavior on the associated WebPart control.
The interface includes two exposed members. The WebBrowsableObject property provides a way for EditorPart controls to get a reference to the associated server control. The CreateEditorParts method is used to create an instance of each custom EditorPart control associated with a server control, and return them as a collection.
The interface is already implemented on the base WebPart class, although by default this implementation does not associate any custom EditorPart controls with the WebPart class. To associate a derived WebPart control with custom EditorPart controls, you can override the CreateEditorParts method.Notes to Implementers
If you want to use server controls that are not WebPart controls in a Web Parts application (that is, if you add these controls to a WebPartZoneBase zone), and if you want to associate custom EditorPart controls with such server controls, you need to implement the interface. Derived WebPart controls should not implement the interface, because the base WebPart class already does so.
The following code example demonstrates how to override the methods of the interface in a custom WebPart control, which then creates an instance of a custom EditorPart control when the WebPart control enters edit mode.
This example has four parts:
The code for the custom class.
The Web page that hosts the custom control.
A user control that switches the page into edit mode.
A description of how the example works in a browser.
The first part of the code example is the custom TextDisplayWebPart class. Notice that the class derives from the WebPart class and implements the interface, providing specific implementations for the CreateEditorParts method and the WebBrowsableObject property. Notice also that nested within the TextDisplayWebPart class is a private, custom TextDisplayEditorPart class that derives from the base EditorPart class. 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 walkthrough that demonstrates 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 hosts the custom control. Notice that although an EditorZone control is declared in the markup of the page, the custom EditorPart control need not be referenced there, because it can be added programmatically at run time.
The third part of the code example is a user control that enables a user to switch the page into edit mode. Notice that the user control is referenced in the hosting Web page. For a full description of how to create this user control, see Walkthrough: Changing Display Modes on a Web Parts Page.
To run the code example, load the hosting Web page in a browser, add some text to the text box, and click the Set Label Content button to update the label in the control. To switch the page into edit mode, select Edit from the drop-down list containing the display modes. To display the UI from the custom TextDisplayEditorPart control, click the verbs menu drop-down arrow on the TextDisplayWebPart control, and select Edit. In the editing UI, you can use the drop-down list containing the font styles to update the text style for the label in the TextDisplayWebPart control. You must click Browse Mode in the display modes drop-down list to return the page to normal view and confirm that the text in the label now has the font style you selected while in edit mode.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.