In New or Edit page, the users might press "close" button by mistake and lost is the content that they have input. To avoid this mistaken action, application should prompt users before the page is closed. This page is not is 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 derived from pagebase.
This class implements the function of ' cause ' to confirm navigating away the ' current page '.
Using System;
Using System.IO;
Using System.Text;
Using System.Text.RegularExpressions;
Using System.Web.UI;
Namespace Proloq.proloqweb
{
<summary>
Would cause the user to confirm navigating away from the current page. This behavior can be overriden.
</summary>
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'll 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. OnPreRender (e);
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.