加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – jQuery模态窗体对话框回发问题

发布时间:2020-12-15 19:08:13 所属栏目:asp.Net 来源:网络整理
导读:我创建了一个 jQuery UI模态窗体,我想要该窗体触发回发,但我有困难得到它的工作。 我知道有相当多的文章基于使用SimpleModal插件,我已经尝试适应这些和重写_doPostback函数,但没有快乐。 我认为问题是在我的__doPostBack函数的调用和什么参数应该。是这
我创建了一个 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"));

这对我有用。回发工作发现。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读