[英]Submit ASP.NET Form within Jquery Remodal
I've created an ASP.NET web page (.aspx) which is using a Jquery plugin containing a subscription form. 我创建了一个ASP.NET网页(.aspx),该网页正在使用包含订阅表单的Jquery插件。
The modal containing the form pops with no problems or errors, but the problem is when I complete the form with data and press the submit button, the form doesn't post back so the C# in codebehind can't process the the form data. 弹出表单的模式不会出现任何问题或错误,但是问题是当我使用数据完成表单并按下提交按钮时,表单不会回发,因此隐藏代码中的C#无法处理表单数据。
This is the JQuery Modal Plugin: http://vodkabears.github.io/remodal/ 这是JQuery Modal插件: http : //vodkabears.github.io/remodal/
Here is the ASP.NET page code: 这是ASP.NET页面代码:
<a href="#" data-remodal-target="modal" class="action-button">Get Free Trial</a>
<div class="remodal" data-remodal-id="modal">
<label>First Name</label>
<asp:TextBox ID="TextBoxFirstName" runat="server" />
<label>Last Name</label>
<asp:TextBox ID="TextBoxLastName" runat="server" />
<label>Email</label>
<asp:TextBox ID="TextBoxEmail" runat="server" />
<asp:button runat="server" ID="ActiveCampaignSend" Text="Subscribe" OnClick="FormSubmit_Click"/>
</div>
Sample of the C# Code Behind: 后面的C#代码示例:
protected void FormSubmit_Click(object sender, EventArgs e)
{
// Code thate processes the form goes here....
}
I've tested the form witout using the Jquery ReModal and it submits and works perfectly. 我已经使用Jquery ReModal测试了witout表单,它可以提交并完美地工作。 I would try and not use a Modal window but my client has specifically requested it happens this way.
我会尝试而不使用Modal窗口,但是我的客户明确要求以这种方式发生。
If someon can help me fix this issue, I'd be really grateful! 如果有人可以帮助我解决此问题,我将不胜感激!
The remodal plugin uses your <div class="remodal" data-remodal-id="modal">
as a prototype to build the dom elements for the modal window. remodal插件使用您的
<div class="remodal" data-remodal-id="modal">
作为原型为模态窗口构建dom元素。 When it does this, it appends them to the body
, outside the form
tag. 执行此操作时,会将它们附加到
form
标签之外的body
。 Thats why they dont interact with your form and you dont get a postback 这就是为什么他们不与您的表单交互并且您没有得到回发的原因
When your asp:button
is clicked, copy the values of email, first and last name inputs to the inside the form and then call submit
on the form
. 单击
asp:button
,将电子邮件的值,名字和姓氏输入复制到表单内部,然后在form
上调用submit
。
After further research, I found this post which fixed the issue: 经过进一步研究,我发现此帖子解决了该问题:
jQuery modal form dialog postback problems jQuery模态表单对话框回发问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.