简体   繁体   English

在Jquery Remodal中提交ASP.NET表单

[英]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.

相关问题 在ASP.NET MVC表单上提交? - Submit on an ASP.NET MVC form? ASP.Net表单的JQuery表单提交:request(txtname)&lt;&gt; txtname.text - Jquery form submit of ASP.Net form : request(txtname) <> txtname.text 使用ASP.NET MVC和jQuery呈现部分视图/提交表单,而无需刷新页面 - Using ASP.NET MVC and jQuery to render partial view/submit a form without page refresh 在ASP.NET MVC 5中使用jQuery成功进行Ajax调用后提交表单 - Submit form after successful ajax call using jQuery in asp.net mvc 5 Asp.Net MVC 5 jQuery验证不适用于带有提交事件的Ajax帖子,显示为有效表单 - Asp.Net MVC 5 Jquery validation not working on ajax post with submit event, showing as valid form 如何在动态创建的表单中使用 JQuery Ajax 将表单数据提交到 ASP.NET 核心 MVC 操作 - How to submit formdata to ASP.NET Core MVC action using JQuery Ajax in a dynamic created form 截取的表单提交在 jQuery 和 ASP.NET MVC 上生成阻塞的 ajax 请求 - Intercepted form submit generates a blocking ajax request on jQuery and ASP.NET MVC ASP.NET 防止 jquery-ocupload 插件制作 form.submit() - ASP.NET prevent jquery-ocupload plugin make form.submit() jQuery,onBeforeUnload和ASP.Net表单 - jQuery, onBeforeUnload and ASP.Net form 在ASP.NET MVC中使用静态和动态控件提交表单 - submit form with static and dynaic controls in ASP.NET MVC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM