public string OnBeforeUnload() { // Setup initial conditions. if (WindowClosing == null) return null; // Check with event-listeners to see if any of them want to cancel the window-close operation. var args = new HtmlWindowCloseEventArgs(); OnWindowClosing(this, args); if (!args.Cancel) return null; // No one wanted to stop the window from closing. // Present the 'Are you sure' dialog to the use (via the browser). var message = args.DialogMessage.AsNullWhenEmpty() != null ? args.DialogMessage : DefaultDialogMessage; return message; }
private void DontCancelOnClose(object sender, HtmlWindowCloseEventArgs e) { Debug.WriteLine("!! Event: WindowClosing (Non-Cancel Handler)"); e.Cancel = false; }
private static void OnWindowClosing(object sender, HtmlWindowCloseEventArgs e) { if (WindowClosing != null) WindowClosing(sender, e); }
private void CancelOnClose(object sender, HtmlWindowCloseEventArgs e) { Debug.WriteLine("!! Event: WindowClosing (Cancel Handler)"); e.DialogMessage = GetMessage(); e.Cancel = true; }