Export (0) Print
Expand All

EditorZoneBase.EditorParts Property

Gets a collection of all the EditorPart controls contained in an EditorZoneBase zone.

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

public EditorPartCollection EditorParts { get; }
/** @property */
public EditorPartCollection get_EditorParts ()

public function get EditorParts () : EditorPartCollection

Not applicable.

Property Value

An EditorPartCollection that contains all the individual EditorPart controls in a zone.

Exception typeCondition

InvalidOperationException

An EditorPart being added to the collection does not have a value assigned to its ID property.

The EditorParts property provides a reference to a collection of all the EditorPart controls in the zone. It references both the EditorPart controls provided with the Web Parts control set, and any custom EditorPart controls that are added to the zone. Because the collection is read-only, developers who want to create custom EditorPart controls for general editing purposes and add them to the collection should override the CreateEditorParts method.

If you design custom EditorPart controls to edit a specific WebPart control, you should override the members of the IWebEditable interface--the CreateEditorParts method and the WebBrowsableObject property--in the WebPart control. The reason to override these members is to enable your WebPart control to create the custom EditorPart controls and add them to the EditorParts collection when your control is being edited, and to provide the editing controls with an object reference to the WebPart control they are editing. If you want to add a custom EditorPart control to edit a server control that does not inherit from the WebPart class, you must implement the IWebEditable interface in the class just as you would for a WebPart control.

NoteNote:

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

The following code example demonstrates how to access the EditorParts property programmatically. For the full code required to run the example, see the Example section of the EditorZoneBase class overview topic.

The first part of the code example demonstrates that the EditorParts property contains references to all the EditorPart controls that are referenced declaratively in the Web page.

<aspSample:MyEditorZone ID="EditorZone1" runat="server">
  <ApplyVerb Text="Apply Changes" />
  <CancelVerb Text="Cancel Changes" />
  <OKVerb Text="Finished" />
  <ZoneTemplate>
    <asp:AppearanceEditorPart ID="AppearanceEditorPart1" 
      runat="server" />
    <asp:LayoutEditorPart ID="LayoutEditorPart1" 
      runat="server" />
  </ZoneTemplate>
</aspSample:MyEditorZone>

The second part of the code example programmatically accesses the EditorParts property and lists the ID of each control in a Label control.

void Button3_Click(object sender, EventArgs e)
{
  Label1.Text = "<br />";
  foreach (EditorPart part in EditorZone1.EditorParts)
  {
    Label1.Text += part.ID + "<br />";
  }
}

When you load the page in a browser, you can click the Display EditorParts Collection button to list the IDs of all the EditorPart controls referenced in the EditorParts property.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft