normally if you want to warn user before he click some button to delete or update something, you can use
Button.Attributes.Add("onclick","return confirm('Are you sure?')");
However, the javascript confirm function is very simple except you can modify some text of it. In some case, you need to perform some additional checking before you pop up the confirm dialog box. For example, in this web application, it only requires the confirm window pop up when the domain the user entered is equal to the user's domain, so you need some custumorized JS function to perform this checking and confirmation.
addWhite.Attributes.Add("onclick","return SameAddress_Confirm();");
where SameAddress_Confirm() is the JS function I wrote to do this:
function SameAddress_Confirm() {
var mydomain = document.all["hJS"].value;
var addWhiteEntry = document.all["addWhiteEntry"].value;
var addBlackEntry = document.all["addBlackEntry"].value;
addWhiteEntry = TrimString(addWhiteEntry).split('@')[1];
addBlackEntry = TrimString(addBlackEntry).split('@')[1];
var ifAdd;
if((mydomain == addBlackEntry)(mydomain==addWhiteEntry))
{ //show confirm message
ifAdd = !confirm("Adding your own email address or domain to this list can have negative results and actually increase the amount of unwanted messages (spam) your inbox receives significantly.\n\nPlease see the help section topic 'Managing your Allowed Senders lists' for specific details\n\nThis entry can still be added by clicking 'cancel' below.");
}
else
ifAdd = true;
return ifAdd;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment