ASP.NET MVC3 Partial View on HTTPPost?

I'm not sure if I totally understand what you are trying to do but if what I'm thinking is right, you should just use.

Up vote 0 down vote favorite share g+ share fb share tw.

I Have a View and Partial View. The layout for the view is something like this: ... @RenderBody() @Html. Action("PartialViewForm", "Main") ... My Partial View (named as _Register) is something like this: @model PartialViewModel @using (Html.

BeginForm("PartialViewForm", "Main", FormMethod. Post)) { @Html. ValidationSummary(true) @Html.

LabelFor(model => model. Name)* @Html. EditorFor(model => model.

Name) @Html. ValidationMessageFor(model => model. Name, "") } In my MainController I have methods like this: public class MainController : Controller { public ActionResult Index() { return View(); } HttpGet public ActionResult PartialViewForm() { var partialViewModel= new PartialViewModel(); return PartialView("_Register", partialViewModel); } HttpPost public ActionResult PartialViewForm(PartialViewModel partialViewModel ) { // if Validation is not successfull return PartialView("_Register", partialViewModel); // else .... } } This is what I want to do... when validation fails on the partial view I want to g back to the main view... however in my case on the post action when validation fails all I can see is the partialview... there is no main page content.

There are posts on the forum that show the same kind of behavior but I am not able to solve my issue. Can anyone please tell me how to fix it (it will be really helpful if you can modify my example and show it) Thanks asp.net asp.net-mvc-3 partial-views link|improve this question asked Aug 3 '11 at 17:20igress174.

I'm not sure if I totally understand what you are trying to do but if what I'm thinking is right, you should just use HttpPost public ActionResult PartialViewForm(PartialViewModel partialViewModel ) { // if Validation is not successfull model = _db.getBlah(); //get the original model for the main view return View("MainView", model); // else .... } However I think your issue might be that you really should have your form submission in your main view and not in your partial - the partial is just there to render the editors for your Create/Edit views, etc; the data should be submitted to the main view's action so that it can create/update the proper model.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions