I'll make this generic:
C# and ASP.Net.
Lets pretend its a delete function:
I want to create a pop-up box client side that asks the user if they're sure they want to delete the record. If they click "OK", thats fine, delete.
BUT!
If they click "Cancel", I want to perform a separate action. I want to capture the "Cancel" click, and call a separate method.
I have tried:
BtnDelete.Attributes.Add("OnClick", "return confirm('Are you sure you want to delete this?');");
But THAT PROVIDES NO CASE FOR THE CANCEL CLICK except to do nothing (cancel the box).
I have also tried:
<script>
function sConfirm()
{
var s = window.confirm("Button Value Test");
if (s)
{
alert("OK");
}
else
{
alert("Cancel")
<%CancelClick();%> //<------This bit!
}
}</script>
Calling a method in the page on click event of the javascript box. BUT! on the page load, it executes that method (CancelClick), before any action has been performed, indeed before the page has even fully loaded. If I wrap CancelClick in an if(Page.IsPostBack), then the page loads, but the code " <%CancelClick();%>" is EXCLUDED from the page HTML!
This should not be this difficult. All I want is a popup box client side that has two outcomes, true and false, and to perform separate and independant actions depending on the outcome.
Please?
ASKER
I'll hold out for a day or so, but your response has given me a "there is another way" grin :)