This documentation is archived and is not being maintained.

IWebEditable Interface

Provides an interface for developers to specify custom editing controls that are associated with a WebPart control.

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

public interface class IWebEditable

The IWebEditable type exposes the following members.

Public propertyWebBrowsableObjectGets a reference to the WebPart control, user control, or custom control that will be edited by EditorPart controls.

Public methodCreateEditorPartsReturns a collection of custom EditorPart controls associated with a server control that implements the IWebEditable interface.

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

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

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

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

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.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

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.