ModuleDialogPage.OnDeactivating(CancelEventArgs) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides a dialog box that asks the user to confirm or cancel pending changes.
protected:
override void OnDeactivating(System::ComponentModel::CancelEventArgs ^ e);
protected override void OnDeactivating (System.ComponentModel.CancelEventArgs e);
override this.OnDeactivating : System.ComponentModel.CancelEventArgs -> unit
Protected Overrides Sub OnDeactivating (e As CancelEventArgs)
Parameters
A CancelEventArgs that contains data about the cancel state.
Examples
The following example duplicates the implementation of the OnDeactivating method.
protected override void OnDeactivating(CancelEventArgs e) {
if (HasChanges && !ReadOnly) {
DialogResult result = ShowMessage(
"Save Changes?",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1
);
if (result == DialogResult.Yes) {
if (CanApplyChanges) {
if (!ApplyChanges()) {
e.Cancel = true;
} else {
// Update the task list so that no
// out of sync alerts are shown
_showDirtyPageAlert = false;
Update();
}
} else {
ShowMessage("Invalid Data In Custom DialogPage");
e.Cancel = true;
return;
}
} else if (result == DialogResult.Cancel) {
e.Cancel = true;
} else if (result == DialogResult.No) {
_showDirtyPageAlert = true;
}
}
}
Remarks
If the Microsoft.Web.Management.Client.Win32.ModulePage.HasChanges property is true
and the Microsoft.Web.Management.Client.Win32.ModulePage.ReadOnly property is false
, the dialog box is displayed; otherwise, the method returns.