troubleshooting Question

C# / ASP.NET popup box with two captured results?

Avatar of wireframe
wireframe asked on
.NET Programming
2 Comments1 Solution2906 ViewsLast Modified:
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?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros