jQuery 模态表单对话框回发问题 [英] jQuery modal form dialog postback problems
问题描述
我创建了一个 jQuery UI 模态表单,我希望该表单触发回发,但我很难让它工作.
我知道有很多文章是基于使用 SimpleModal 插件的,我已经尝试改编这些文章并覆盖 _doPostback 函数,但没有任何乐趣.
我认为问题在于对我的 __doPostBack 函数的调用以及参数应该是什么.是这样吗?
这是我的表格
//--------------------------------
这是 JavaScript 代码:
创建对话框后,只需将对话框移回表单即可.示例:
$("#divSaveAs").dialog({bgiframe:false,自动打开:假,title:"另存为",模态:真});$("#divSaveAs").parent().appendTo($("form:first"));
这对我有用.回发作品查找.
I've created a jQuery UI Modal form, and I want that form to trigger a postback, but I'm having difficulty getting it to work.
I know there are quite a few articles based on using the SimpleModal plugin, and I have tried to adapt these and override the _doPostback function, but with no joy.
I think the problem is within the call to my __doPostBack function and what the parameters should be. Is that the case?
Here's my form
<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>
//--------------------------------
Here is the JavaScript code:
<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>
After creating your dialog simply move the dialog back into your form. Example:
$("#divSaveAs").dialog({bgiframe:false,
autoOpen:false,
title:"Save As",
modal:true});
$("#divSaveAs").parent().appendTo($("form:first"));
This worked for me. Postback works find.
这篇关于jQuery 模态表单对话框回发问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!