Pop up confirm message to appear on condition

1.4k Views Asked by At

I am trying to set up a Confirm dialogue which works as follows:

When user clicks on Export button, calculations are done in the code-behind to work out how many rows to export. If row number exceeds a threshold (e.g. 1 million rows), the pop-up confirm message appears and asks if user would like to batch export and receive email when job is done.

I've been using this solution so far (obtained from here):

Javascript:

        function Confirm() {
        var confirm_value = document.createElement("INPUT");
        confirm_value.type = "hidden";
        confirm_value.name = "confirm_value";
        if (confirm("Do you want to batch export data?")) {
            confirm_value.value = "Yes";
        } else {
            confirm_value.value = "No";
        }
        document.forms[0].appendChild(confirm_value);
    }

Code-Behind

                string confirmValue = Request.Form["confirm_value"];
            if (confirmValue == "Yes")
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "alert", "alert('You clicked YES!')", true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "alert", "alert('You clicked NO!')", true);
            }

The the only problem I have is that regardless of whether the row number exceeds the threshold or not, the pop up confirm message appears, which is not what I want.

I want the pop up message to ONLY appear if the calculated row number exceed the threshold.

Any ideas?

0

There are 0 best solutions below