Hello,
I am creating a web application in ASP.NET MVC 3.0
In my View, I need to get a PartialView which uses a different model other than the model which is used by the rendering view. Hence I have used RenderAction() method to display the PartialView in the rendering View.
I was successful in displaying the PartialView but now I got a problem.
When I click on Submit button, the overload action method in the controller with
[HttpPost]
is not called. Please help me in finding out where am I going wrong.
HomeController.cs
public ViewResult CreateReminder()
{
CreateReminder modelCreateReminder = new CreateReminder();
return View();
}
[HttpPost]
public ActionResult CreateReminder(string submit, CreateReminder model)
{
return View();
}
CreateReminder.cshtml
@model ReminderService.Models.CreateReminder
<body>
@using (Html.BeginForm("CreateReminder", "Home", FormMethod.Post))
{
<p>Subject: @Html.TextBoxFor(m => m.subject)</p>
<p>Location: @Html.TextBoxFor(m => m.location)</p>
<p>Start Time:@{Html.RenderAction("GetCalendar", "Home");}</p>
<p>End Time:@{Html.RenderAction("GetCalendar", "Home");}</p>
<input type="submit" name="submit" value="Submit" />
<input type="submit" name="cancel" value="Cancel" />
}
</body>
Note: If I remove the code lines with RenderAction(), then the overload action method with POST attribute is getting invoked.