A universal confirmation page class

xiaoxiao2021-03-06  54

Confirmation Page

INTRODUCTION

In New or Edit page, users might press the Close button by mistake and lost the content that they have input. To avoid this mistaken action, application should prompt users before the page is closed. This page will not be closed unless users confirm that.

This Document Gives The Implementation Details for How The Confirmation Page Works. It can be used in:

Ÿ New page

Ÿ Edit Page

Ÿ Any Other Pages Need Confirmation Before Close

2. Solution

2.1 ConfirmationPage Class

ConfirmationPage Class Is Available in The Root of XxxWeb Project. This is a class deive from pagebase.

This Class Implements The function of "cause the user to confirm Navigating Away from The Current Page".

Using system; using system.text; using system.text.regulareXpressions; using system.web.u;

namespace Proloq.ProloqWeb {///

/// Will cause the user to confirm navigating away from the current page This behavior can be overriden /// public class ConfirmationPage:.. Proloq.ProloqWeb.PageBase { public ConfirmationPage () {} private bool _IsInEdit = false; public bool IsInEdit {get {return this._IsInEdit;} set {this._IsInEdit = value;}} private string _message = "You will lose any non-saved text"; public string Message {get {return _message;} set {_message = value;}} protected override void OnPreRender (EventArgs e) {// If we are in edit mode, register the script if (IsInEdit) {Page.RegisterClientScriptBlock ( "ConfirmationBeforeLeaving" String.format ("{0} {1} {2}", scriptstart, message, scriptend);} base.onprender (e);} const string scriptstart = "