Avatar of wireframe
wireframe

asked on 

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

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?
.NET Programming

Avatar of undefined
Last Comment
wireframe
ASKER CERTIFIED SOLUTION
Avatar of ChadMarsh
ChadMarsh
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of wireframe
wireframe

ASKER

its good, I'll give you that. Create your OWN "messagebox" and capture the clicks from two separate buttons. I do like it. Infact, if another soluton doesn't present itself, you'll win the points. BUT there MUST be functionality for this, surely? It seems improbably that an indusry strength language cannot provide me with more than 1 buttonclick capture....
I'll hold out for a day or so, but your response has given me a "there is another way" grin :)
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo