संपादित करें

इसके माध्यम से साझा किया गया


EditorZoneBase.OnSelectedWebPartChanged(Object, WebPartEventArgs) Method

Definition

Raises the SelectedWebPartChanged event and sets the EditorParts collection to null in the zone in preparation for a WebPart control to enter or exit edit mode.

protected:
 override void OnSelectedWebPartChanged(System::Object ^ sender, System::Web::UI::WebControls::WebParts::WebPartEventArgs ^ e);
protected override void OnSelectedWebPartChanged (object sender, System.Web.UI.WebControls.WebParts.WebPartEventArgs e);
override this.OnSelectedWebPartChanged : obj * System.Web.UI.WebControls.WebParts.WebPartEventArgs -> unit
Protected Overrides Sub OnSelectedWebPartChanged (sender As Object, e As WebPartEventArgs)

Parameters

sender
Object

An Object that raises the SelectedWebPartChanged event.

e
WebPartEventArgs

A WebPartDisplayModeEventArgs that contains the event data.

Examples

The following code example demonstrates how to override the OnSelectedWebPartChanged method in a derived class. For the full code required to run the example, see the Example section of the EditorZoneBase class overview topic.

The custom editor zone derives from the EditorZone class so that it can be used with a zone template in the declarative markup of the Web page. The custom class overrides the OnSelectedWebPartChanged method, setting the background color of the specific control that is being edited, and then calls the base method.

protected override void OnSelectedWebPartChanged(object sender, 
  WebPartEventArgs e)
{
  if (e.WebPart != null)
    e.WebPart.Zone.SelectedPartChromeStyle.BackColor = 
      Color.LightGreen;
  base.OnSelectedWebPartChanged(sender, e);
}
Protected Overrides Sub OnSelectedWebPartChanged(ByVal sender _
  As Object, ByVal e As WebPartEventArgs)
  If Not (e.WebPart Is Nothing) Then
    e.WebPart.Zone.SelectedPartChromeStyle.BackColor = _
      Color.LightGreen
  End If
  MyBase.OnSelectedWebPartChanged(sender, e)

End Sub

When you load the page in a browser, you can select Edit Mode in the drop-down list control to switch to edit mode. You can click the verbs menu (the down arrow) in the title bar of one of the controls, and click Edit to edit the selected control. When the EditorZone and editing user interface (UI) are visible, you can see that the selected control has the background color specified in the code.

Remarks

The OnSelectedWebPartChanged method enables you to provide custom handling for the event that occurs when an individual WebPart control enters or exits edit mode.

Notes to Inheritors

The OnSelectedWebPartChanged(Object, WebPartEventArgs) method can be overridden or called programmatically in a custom editor zone control that inherits from the EditorZoneBase class or the EditorZone class.

Applies to

See also