asp.net - jQuery 模态表单对话框回发问题

标签 asp.net jquery-ui postback

我创建了一个 jQuery UI模态表单,我希望该表单触发回发,但我很难让它工作。

我知道有很多文章是基于使用 SimpleModal 插件的,我尝试过改编这些文章并覆盖 _doPostback 函数,但没有任何乐趣。

我认为问题在于对 __doPostBack 函数的调用以及参数应该是什么。是这样吗?

这是我的表格

<form id="summaryForm" runat="server">
    <div id="dialog" title="Quick Booking">
        <p>Select user from list or enter name in box</p>
        <fieldset>
            <p><label>Is machine going out of the office?</label></p>
            <asp:RadioButton  TextAlign="Left" GroupName="outOfOffice" Text="Yes" ID="optYes" class="radio" runat="server" />
            <asp:RadioButton  TextAlign="Left" GroupName="outOfOffice" Text="No" ID="optNo" class="radio" runat="server" Checked="true" />

            <label for="dropLstUser">User:</label>
            <asp:DropDownList ID="dropLstUser" runat="server" />
            <input type="text" name="txtUser" id="txtUser" value="" class="text" />
            <label for="txtStartDate">Start Date:</label>
            <input type="text" id="txtStartDate" name="txtStartDate" class="datepicker" />
            <asp:HiddenField ID="assetField" runat="server" />
            <%--<button onclick="performPostBack('summaryForm')">Postback</button>--%>
        </fieldset>
    </div>
    //--------------------------------

这是 JavaScript 代码:

<script type="text/javascript">
    $(function() {
        $("#dialog").dialog({
            bgiframe: true,
            height: 300,
            modal: true,
            buttons: {
                'Close': function() {
                             alert("closing");
                             $(this).dialog("close");
                             __doPostBack = newDoPostBack;
                             __doPostBack("aspnetForm",null);
                         }
            }
        });
    });

    function newDoPostBack(eventTarget, eventArgument)
    {
        alert("postingback");
        var theForm = document.forms[0];

        if (!theForm)
        {
            theForm = document.aspnetForm;
        }

        if (!theForm.onsubmit || (theForm.onsubmit() != false))
        {
            document.getElementById("__EVENTTARGET").value = eventTarget;
            document.getElementById("__EVENTARGUMENT").value = eventArgument;
            theForm.submit();
        }
    }
</script>

最佳答案

创建对话框后,只需将对话框移回表单即可。示例:

 $("#divSaveAs").dialog({bgiframe:false,
                            autoOpen:false,
                            title:"Save As",
                            modal:true});
    $("#divSaveAs").parent().appendTo($("form:first"));

这对我有用。回发作品找到。

关于asp.net - jQuery 模态表单对话框回发问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/568784/

相关文章:

c# - 如何在 HTMLGenericControl 上注册服务器端点击?

c# - 使用 ASP.NET Core 反序列化 appsettings.json

jquery - jQuery 中的输入框动画留下 "trail",有什么办法摆脱它吗?

javascript - jQueryUI 按钮显示操作的子菜单

c# - 如何在异步回发期间重定向浏览器?

.net - 在更新面板中提交表单后运行 javascript?

c# - 使用 dt.select 填充下拉列表

文字中的 asp.net 数据绑定(bind)

jquery - Div 没有环绕整个页面的宽度

javascript - jQuery Accordion 打开后立即关闭