0

i'm trying to replace the standard javascript confirm function with a JQueryUI dialog. I've searched for solutions, but nothing seems to work for me. What i want is simple: click an ASP.Net button, display the dialog, continue if "Yes" is pressed. Current javascript code:

    $(document).ready(function () {

        $("#confirmDialog").dialog({
            autoOpen: false,
            modal: true,
            closeOnEscape: false,
            bgiframe: true,
            open: function (event, ui) { $(".ui-dialog-titlebar-close", ui.dialog).hide() },
            buttons: {
                "Yes": function () {
                    $(this).dialog('close');
                    return true;
                },
                "No": function () {
                    $(this).dialog('close');
                    return false;
                }
            }
        });
    });

    function showDialog() {
        $("#confirmDialog").dialog('open');
        return false;
    }

ASP.NET code:

            <asp:Button ID="DeleteButton" CssClass='button' onmouseout="this.className='button'"
                onmouseover="this.className='button:hover'" runat='server' Text='Delete' Width='1in'
                Height="30px" OnClientClick="javascript:showDialog();" OnClick="DeleteSetup"/>

What's happening is that the dialog is displayed, but DeleteSetup vb.net sub is called before anything is selected in the dialog.

Thanks in advance for any help or advice.

2
  • jQuery dialog doesn't block a javascript execution. So everytime showDialog function will return false value and server side event wasn't fired. Commented Jul 19, 2011 at 13:29
  • Put the DeleteSetup inside "Yes" function callback. Commented Jul 20, 2011 at 0:38

1 Answer 1

5

Try changing your OnClientClick declaration to this

OnClientClick="return showDialog();"

Sign up to request clarification or add additional context in comments.

1 Comment

I changed the OnClientClick as recommended, but that didn't help. The dialog appears, but processing continues, the OnClick event fires (even though the dialog was declared modal). I'm sure the reason this i can't make this work is my lack of understanding (though i've tried). All i want is for this dialog to behave like the standard javascript confirm function. How? Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.