c# - How do I save my MVC4 model if I need 2 submit buttons? -
I have to allow the user to go to the next or previous form, I have to save the model on the navigation. Apart from submitting the controller, is there another way to return the model? Since I need to redirect to other possible pages.
You can put your model object in the TempData collection Submit, redirect, then it again Read. For example:
[HTTP post] Public ActionResult Firstform (First Form Modell Model) {TempData ["TempModelStorage"] = Model; Return Redirect Action ("Second Form"); } Public Action Second Form () {var firstModel = TempData ["TempModelStorage"] as FirstFormModel; // Use redundant checks, as appropriate, etc. See Return (...); } More details here:
Comments
Post a Comment