【发布时间】:2013-06-26 11:17:27
【问题描述】:
您好,我的页面有问题。我在同一页面中有一个视图页面和 2 个表单。
问题是我有一个主窗体和另一个由 JQuery 显示的窗体。我的问题是当我打开对话框,提交表单并返回视图时,对话框消失了。我不知道如何返回仍然会显示打开的对话框的结果。
我需要你的帮助!
以下是我在应用程序中使用的代码。
.CSTHML 表单
@using (Html.BeginForm("Login2", "Account", FormMethod.Post, new { @id = "loginForm" }))
{
<a id="submitlink" href="#" class="button button-large">Sign In</a>
}
// This is the pop-up dialog box
@using (Html.BeginForm("TroubleSubmit", "Account", FormMethod.Post, new { @id = "troubleSubmitForm" }))
{
<a id="troubleSubmitLink" href="#" class="button">OK</a>
}
JQUERY
$('a#submitlink').click(function () {
$('#loginForm').submit();
});
$('a#troubleSubmitlink').click(function () {
$('#troubleSubmitForm').submit();
});
以下是处理对话框表单提交的控制器操作代码:
public ActionResult SignInTrouble(some parameter...)
{
// some operation and validation here
return View(); // ??? What view will I return? When I return "Login" it will reload the page and close the dialog box.
}
再次,我如何返回仍将显示对话框的视图
【问题讨论】:
-
提交表单后,页面会重新加载。如果您不想重新加载页面,则应该使用 AJAX 请求。
-
或者 iFrame,我认为 jQuery 对话框会处理它们
-
你能给我一些示例代码吗?
标签: asp.net asp.net-mvc-4