Javascript Confrmation Box, Executing Code Behind Only If Clicked Yes
This is following my previous question.. How to reload parent page on closing PopUp window? I tried a combination of things but could not make it work.. Sometimes the code behind e
Solution 1:
Have a look at this
function Refresh() {
var confirmed = confirm('Are you sure?');
if (confirmed) {
window.onunload = refreshParent;
return true;
} else {
return false;
}
}
function refreshParent() {
window.opener.location.reload();
}
Solution 2:
Try this
function Refresh() {
var myBoolean = new Boolean();
if (confirm('Are you sure?')) {
window.onunload = refreshParent;
function refreshParent() {
window.opener.location.reload();
return true;
}
}
else {return false;}
}
Solution 3:
Don't use a server-side button. Those elements are meant to execute an action in the server.
So guess what? for executing the action on the server this needs to happen:
- The browser submits the form making a POST request
- The server parses the form data and identifies which button was pressed
- The server calls the registered event handler for the button.
So, in your case I would cancel the onclick event of the button in client side. Or simpler... just use a normal HTML button.
<button id="btnAccept" onclick="Refresh()" style="HEIGHT: 19px;background: #C0003B;color: white; "> Accept </button>
Post a Comment for "Javascript Confrmation Box, Executing Code Behind Only If Clicked Yes"