小编典典

带ASP.NET按钮回发的jQuery UI对话框

c#

我的jQuery UI对话框在我的ASP.NET页上运行良好:

jQuery(function() {
    jQuery("#dialog").dialog({
        draggable: true,
        resizable: true,
        show: 'Transfer',
        hide: 'Transfer',
        width: 320,
        autoOpen: false,
        minHeight: 10,
        minwidth: 10
    });
});

jQuery(document).ready(function() {
    jQuery("#button_id").click(function(e) {
        jQuery('#dialog').dialog('option', 'position', [e.pageX + 10, e.pageY + 10]);
        jQuery('#dialog').dialog('open');
    });
});

我的div:

<div id="dialog" style="text-align: left;display: none;">
    <asp:Button ID="btnButton" runat="server" Text="Button" onclick="btnButton_Click" />
</div>

但是btnButton_Click从未被调用…我该如何解决?

更多信息:我添加了以下代码以将div移动到表单:

jQuery("#dialog").parent().appendTo(jQuery("form:first"));

但是仍然没有成功…


阅读 250

收藏
2020-05-19

共1个答案

小编典典

您接近解决方案,只是得到了错误的对象。应该是这样的:

jQuery(function() {
    var dlg = jQuery("#dialog").dialog({
                         draggable: true,
                         resizable: true,
                         show: 'Transfer',
                         hide: 'Transfer',
                         width: 320,
                         autoOpen: false,
                         minHeight: 10,
                         minwidth: 10
                     });
    dlg.parent().appendTo(jQuery("form:first"));
});
2020-05-19