1

I am trying display confirm dialog box after submit and do the rest of the process i am using following code but i click confirm nothing is happening.

button :

<asp:linkbutton id="btnSubmit" runat="server" validationgroup="grpContact" cssclass="greyBtn" OnClick="btnSubmit_Click"> Submit</asp:linkbutton>

Jquery:

$(document).ready(function () {
        $("#<%=btnSubmit.ClientID %>").click(function () {
            var validated = Page_ClientValidate('grpContact');
            if (validated) {
                $("#dialog").dialog({
                    buttons: {

                        "Confirm": function () {

                            $("#<%=btnSubmit.ClientID %>").submit();
                            $(this).dialog("close");
                            return true;

                        },
                        "Cancel": function () {
                            $(this).dialog("close");
                            return false;
                        }

                    }
                });
            } return false;
        });

2 Answers 2

1

Try using preventDefault()
Here's an example:

$(document).ready(function () {
            $("#<%=btnSubmit.ClientID %>").on("click", function(e) {
            e.preventDefault();
            var validated = Page_ClientValidate('grpContact');
            if (validated) {
                $("#dialog").dialog({
                    buttons: {

                        "Confirm": function () {

                            $("#<%=btnSubmit.ClientID %>").submit();
                            $(this).dialog("close");
                            return true;

                        },
                        "Cancel": function () {
                            $(this).dialog("close");
                            return false;
                        }

                    }
                });
            } return false;
        });
1
  • 1
    what should be in confirm button
    – raky
    Jan 16, 2013 at 0:04
0

Try like this:

    <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" OnClientClick="return showTermsAndConditions(this);" Style="height: 26px" Text="Submit" ValidationGroup="GrpSubmit" />
var confirmed = false;
    function showTermsAndConditions(obj) {

                $("#dialogTermsAndConditions").dialog({
                    height: 650,
                    width: 800,
                    buttons: {
                        "Yes": function () {
                            $(this).dialog("close");
                            confirmed = true; obj.click();
                        },
                        "No": function () {
                            $(this).dialog("close");
                        }
                    }
                });
                return confirmed;
            }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.