Muokkaa

Jaa


EditorZoneBase.EditorParts Property

Definition

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

public:
 property System::Web::UI::WebControls::WebParts::EditorPartCollection ^ EditorParts { System::Web::UI::WebControls::WebParts::EditorPartCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.UI.WebControls.WebParts.EditorPartCollection EditorParts { get; }
[<System.ComponentModel.Browsable(false)>]
member this.EditorParts : System.Web.UI.WebControls.WebParts.EditorPartCollection
Public ReadOnly Property EditorParts As EditorPartCollection

Property Value

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

Attributes

Exceptions

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

Examples

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>
<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 />";
  }
}
Sub Button3_Click(ByVal sender As Object, ByVal e As EventArgs)
  Label1.Text = "<br />"
  Dim part As EditorPart
  For Each part In EditorZone1.EditorParts
    Label1.Text += part.ID + "<br />"
  Next part
End Sub

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.

Remarks

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.

Note

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.

Applies to

See also