仍然试图解决这个问题,这是我的工作流程:
<div id = "messageForm">...</div>
部分下面是表单视图:
//SignUp.cshtml:
<div id ="messageForm">
@using (Ajax.BeginForm("SignUp", "MVP", new AjaxOptions
{
Confirm = "Are you sure you want to send this message?",
HttpMethod = "Post",
InsertionMode = InsertionMode.Replace,
LoadingElementId = "loading",
UpdateTargetId = "messageForm"
})) {
@Html.AntiForgeryToken();
@Html.ValidationSummary(true)
<fieldset>
<legend>
messageModel
</legend>
<p>
<input type ="submit" value ="Send Message" />
</p>
</fieldset>
这是控制器:
//MVPController
[HttpPost]
public ActionResult SignUp(MVCView model){
return PartialView("_ThankYou");
}
public ActionResult SignUp(){
return View();
}
以下是视图文件夹中的局部视图:
ThankYou.cshtml:
<h1>Thank you so much! We will contact you later</h1>
测试时,我没有看到确认对话框,而是重定向到感谢页面
有谁能告诉我为什么会这样?
答案 0 :(得分:1)
你有:
@using (Ajax.BeginForm("ThankYou", "MVP", new AjaxOptions
我认为这应该是:
@using (Ajax.BeginForm("SignUp", "MVP", new AjaxOptions
第一个字符串是操作名称,您在控制器中只有SignUp
。