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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -