jQuery的模式窗体对话框的回发问题 [英] jQuery modal form dialog postback problems
问题描述
我创建了一个 jQuery UI的模态的形式,我想这种形式触发回传,但我有困难得到它的工作。
我知道有基于使用SimpleModal插件好几篇文章,我试图适应这些和重写_doPostBack功能,但没有喜悦。
我认为这个问题是调用我的__doPostBack函数,什么参数应之内。是这样吗?
下面是我的形式
<表ID =summaryForm=服务器>
< DIV ID =对话称号=快速预订>
< P>从列表中选择用户或箱&LT输入名称; / P>
<&字段集GT;
< P><标签>是机器走出办公室<?/标签>< / P>
< ASP:单选按钮设置textAlign =左组名=outOfOffice文本=是ID =optYes级=电台=服务器/>
< ASP:单选按钮设置textAlign =左组名=outOfOffice文本=否ID =optNo级=电台=服务器选中=真/> <标签=dropLstUser>用户:LT; /标签>
< ASP:DropDownList的ID =dropLstUser=服务器/>
<输入类型=文本名称=txtUserID =txtUserVALUE =级=TEXT/>
<标签=txtStartDate>起始日期:< /标签>
<输入类型=文本ID =txtStartDateNAME =txtStartDate级=日期选择/>
< ASP:HiddenField ID =assetField=服务器/>
<% - <按钮的onclick =performPostBack('summaryForm')>回发< /按钮> - %GT;
< /字段集>
< / DIV>
// --------------------------------
下面是JavaScript code:
<脚本类型=文/ JavaScript的>
$(函数(){
$(#对话)。对话框({
bgiframe:真实,
高度:300,
模式:真实,
纽扣: {
关闭:功能(){
警报(关);
$(本).dialog(亲密);
__doPostBack = newDoPostBack;
__doPostBack(aspnetForm,NULL);
}
}
});
}); 功能newDoPostBack(的eventTarget,eventArgument)
{
警报(postingback);
变种theForm = document.forms [0]; 如果(!theForm)
{
theForm = document.aspnetForm;
} 如果(!theForm.onsubmit ||(theForm.onsubmit()!= FALSE))
{
的document.getElementById(__ EVENTTARGET)值=的eventTarget。
的document.getElementById(__ EVENTARGUMENT)值= eventArgument。
theForm.submit();
}
}
< / SCRIPT>
创建对话框只需移动对话框回到你的表格后。例如:
$(#divSaveAs)对话框({bgiframe:假的,
的AutoOpen:假的,
标题:另存为,
模式:真});
。$(#divSaveAs)父()appendTo($(形式:一是));
这为我工作。回发的作品找到。
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屋!