EditorZoneBase.OnDisplayModeChanged Method

Definition

Raises the DisplayModeChanged event and destroys all EditorPart and child controls in the zone in preparation for a Web page to enter or exit the edit display mode.

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

Parameters

sender
Object

An Object that raises the DisplayModeChanged event.

e
WebPartDisplayModeEventArgs

A WebPartDisplayModeEventArgs that contains the event data.

Examples

The following code example demonstrates how to override the OnDisplayModeChanged 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 OnDisplayModeChanged method, setting the background color of the zone to a specified color, and then calls the base method, which destroys all child and EditorPart controls in preparation for entering or exiting edit display mode.

protected override void OnDisplayModeChanged(object sender, 
  WebPartDisplayModeEventArgs e)
{
  this.BackColor = Color.LightGray;
  base.OnDisplayModeChanged(sender, e);
}
Protected Overrides Sub OnDisplayModeChanged(ByVal sender _
  As Object, ByVal e As WebPartDisplayModeEventArgs)
  Me.BackColor = Color.LightGray
  MyBase.OnDisplayModeChanged(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 control and editing user interface (UI) are visible, you can see that the zone has the background color specified in the code.

Remarks

The OnDisplayModeChanged method provides an implementation for the base method in the ToolZone class.

The main purpose of the OnDisplayModeChanged method is to prepare a Web page to enter or exit the edit display mode. The method destroys all controls contained in the zone and then calls the base method, which raises the DisplayModeChanged event in the WebPartManager control.

Notes to Inheritors

The OnDisplayModeChanged(Object, WebPartDisplayModeEventArgs) 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