rht341
rht341

Reputation: 841

Using JQueryUI dialog in ASP.NET

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.

Upvotes: 0

Views: 682

Answers (1)

Claudio Redi
Claudio Redi

Reputation: 68400

Try changing your OnClientClick declaration to this

OnClientClick="return showDialog();"

Upvotes: 5

Related Questions