EditorPartCollection Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Contains a collection of EditorPart controls used for editing the properties, layout, appearance, and behavior of WebPart controls. This class cannot be inherited.

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


public ref class EditorPartCollection sealed : ReadOnlyCollectionBase


Initializes an empty new instance of the EditorPartCollection class.

System_CAPS_pubmethodEditorPartCollection(EditorPartCollection^, ICollection^)

Initializes a new instance of the EditorPartCollection class by passing in an EditorPartCollection collection of EditorPart controls, and an ICollection collection of additional EditorPart controls.


Initializes a new instance of the EditorPartCollection class by passing in an ICollection collection of EditorPart controls.


Gets the number of elements contained in the ReadOnlyCollectionBase instance.(Inherited from ReadOnlyCollectionBase.)


Returns a specific member of the collection according to a unique identifier.


Returns a value that indicates whether a particular control is in the collection.

System_CAPS_pubmethodCopyTo(array<EditorPart^>^, Int32)

Copies the collection to an array of EditorPart controls.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Returns an enumerator that iterates through the ReadOnlyCollectionBase instance.(Inherited from ReadOnlyCollectionBase.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Returns the position of a particular member of the collection.


Returns a string that represents the current object.(Inherited from Object.)


References a static, read-only, empty instance of the collection.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection::CopyTo(Array^, Int32)

Copies the entire ReadOnlyCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.(Inherited from ReadOnlyCollectionBase.)


Gets a value indicating whether access to a ReadOnlyCollectionBase object is synchronized (thread safe).(Inherited from ReadOnlyCollectionBase.)


Gets an object that can be used to synchronize access to a ReadOnlyCollectionBase object.(Inherited from ReadOnlyCollectionBase.)


Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)


Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)


Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)


Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

The EditorPartCollection class is a read-only collection of EditorPart controls, typically used by an EditorZoneBase zone to track the set of EditorPart controls contained by the zone.

When a Web Parts page enters edit mode, and a user selects a control to edit, the editing process begins. The zone creates a new EditorPartCollection object consisting of the EditorPart controls contained by the zone. At various phases in the editing process, the zone accesses the EditorPartCollection object to save or retrieve property values between the EditorPart controls in the collection and the WebPart control currently being edited.

You can create an EditorPartCollection collection of controls for your own programmatic use if, for example, you need to perform some mass operation on a set of EditorPart controls. Even though the EditorPartCollection object is read-only, you can make programmatic changes to the properties of the underlying controls referenced in the collection.

The following code example demonstrates several uses of the EditorPartCollection class. There are four parts to this code example:

  • A user control that enables you to change display modes on a Web Parts page.

  • A class for a custom WebPart control named TextDisplayWebPart, which is referenced in the Web page and is edited by the EditorPart controls.

  • A Web page that references the TextDisplayWebPart control, contains an EditorZone control with several of the EditorPart controls from the Web Parts control set declared in the zone, and contains some event-driven code to create and manipulate an EditorPartCollection object.

  • An explanation of how the code example works when you load it 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 TextDisplayWebPart control. 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.

Note that the control has a property named ContentText; this property holds the value that the user enters in the text box. This custom property can be edited when the control is in edit mode, along with the standard WebPart control properties.

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

The third part of the code example is the Web page. Notice that the <asp:editorzone> element for the page contains declarations for three EditorPart controls. Two of these controls become part of a custom EditorPartCollection object that is created when the Button1_Click method executes.

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

When you load the page in a browser, you can switch the page into edit mode by selecting Edit in the Display Mode drop-down list control. You can 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 user interface (UI) is visible, you can see all the EditorPart controls. You click the Create EditorPartCollection button to see the effects on the EditorPart controls that are created by the code that is manipulating the EditorPartCollection object. Also, notice that the PropertyGridEditorPart control allows you to edit the custom TextDisplayWebPart.ContentText property. This is possible because the property is marked with a WebBrowsable attribute in the source code for the control. If you update the property value in the editing UI, you must return the page to normal browse mode to see the effect of updating the TextDisplayWebPart.ContentText property.

.NET Framework
Available since 2.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top