This documentation is archived and is not being maintained.

IWebEditable.CreateEditorParts Method

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

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

EditorPartCollection CreateEditorParts()

Return Value

Type: System.Web.UI.WebControls.WebParts.EditorPartCollection
An EditorPartCollection that contains the collection of custom EditorPart controls associated with a server control.

The CreateEditorParts method enables you to create a collection of all the custom EditorPart controls associated with your custom control, WebPart control, or user control, and return them as an EditorPartCollection object. The WebPartManager control takes the collection and creates instances of all the EditorPart controls whenever the server control enters edit mode.

Typically you implement this method in a custom WebPart control by overriding its CreateEditorParts method. In the method, you create instances of the custom EditorPart controls you want to associate with your controls, add them to an EditorPartCollection object, and then return that object. The collection of EditorPart controls is then assigned to the EditorParts property of the EditorZoneBase zone.


Any EditorPart that is added to the collection of EditorPart controls in an implementation of the CreateEditorParts method must have a value assigned to its ID property, otherwise an exception will be thrown when the collection is assigned to the EditorParts property.

Notes to Implementers

The EditorPartCollection object that the CreateEditorParts method returns is read-only and has no accessible method to add individual controls to it. However, in your override or implementation of the method, you can create another kind of ICollection object, such as an ArrayList, to contain all the custom EditorPart controls, and pass it to the constructor when you create a new EditorPartCollection object. For a code example, see the Example section.

The following code example demonstrates an override of the CreateEditorParts method in a custom WebPart control. The complete source code required to run the sample is found in the Example section of the IWebEditable class overview topic.

The code example contains both members of the IWebEditable interface. Note that the override of the CreateEditorParts method creates an ArrayList to collect one or more custom EditorPart controls, and then uses the list to create the EditorPartCollection object.

public override EditorPartCollection CreateEditorParts()
  ArrayList editorArray = new ArrayList();
  TextDisplayEditorPart edPart = new TextDisplayEditorPart();
  edPart.ID = this.ID + "_editorPart1";
  EditorPartCollection editorParts = 
    new EditorPartCollection(editorArray);
  return editorParts;

public override object WebBrowsableObject
  get { return this; }

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