Reputation: 1114
Still trying to figure that out, here is my workflow:
<div id = "messageForm">...</div>
partbelow is the form view:
//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>
here is the controller:
//MVPController
[HttpPost]
public ActionResult SignUp(MVCView model){
return PartialView("_ThankYou");
}
public ActionResult SignUp(){
return View();
}
Here is the partial view in view folder:
ThankYou.cshtml:
<h1>Thank you so much! We will contact you later</h1>
When testing it, I didn't see the confirm dialog and it redirect to the thank you page
Can anyone tell me why that happened?
Upvotes: 0
Views: 207
Reputation: 18769
You have:
@using (Ajax.BeginForm("ThankYou", "MVP", new AjaxOptions
I think this should be:
@using (Ajax.BeginForm("SignUp", "MVP", new AjaxOptions
The first string is the Action name, and you only have SignUp
in the controller.
Upvotes: 1