简体   繁体   中英

jQuery dialog not opening on button click - asp.net web page

I'm new to jQuery and am struggling with opening a jQuery dialog when a user clicks the page submit button; any help would be greatly appreciated!

I've searched other posts, google, etc, but apparently still don't quite understand. I'm including the relevant parts of code below. Just fyi, I'm using Telerik controls, and the submit button is within a table. This is one page within a rather large asp.net/vb.net web app which does use a master page.

Ultimately I'd like to provide the user a Yes, No, Cancel dialog, but at this point I'm just trying to get a dialog to simply open.

<script type="text/javascript">
function confirmSubmit2(sender, args) {
    var rblNextStep = document.getElementById("<%= cbNextStep.ClientID %>");
    var radioButtons = rblNextStep.getElementsByTagName('input');
    var selectedButton = radioButtons.length - 1;

    if (radioButtons[selectedButton].checked) {
        var hasItems = document.getElementById('<% =hfHasItems.ClientId %>').value

        if (parseInt(hasItems) != 0)
            jQuery("#dialog").dialog('open');
    }
}

    $(function () {
        $("#dialog").dialog({
            resizable: false,
            height: 140,
            modal: true,
            buttons: {
                "Delete all items": function () {
                    $(this).dialog("close");
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            }
        });
    });

<td style="font-family: Times New Roman; font-size: medium; width: 33%; text-align: left;">
    <div id="dialog">
     <asp:Panel ID="btnSubmitWrapper" runat="server">
        <telerik:RadButton ID="btnSelSubmit" runat="server" Skin="Sunset" Text="Submit"
            ValidationGroup="Review" Width="98%" OnClientClicked="confirmSubmit2"
            SingleClick="true" SingleClickText="Submitting..." DisabledButtonCssClass="btnDisable">
        </telerik:RadButton>
    </asp:Panel>
    </div>
</td>

Thanks!

It looks like you aren't really calling the dialog plugin correctly.

To get the Dialog to open, why not just use jquery and do something like this to wire up the click event.

$("#<%=btnSelSubmit.ClientID %>").click(function () {
    var dlg = $("#Dialog").dialog({
        title: "Something here",
        autoOpen: true,
        width: 600,
        modal: true
        }
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM