views:

38

answers:

2

I have a complex page with several forms on it. The page is divided into sections, and each section has a continue button on it.

The page is bound to a pageViewModel, each section addresses a different set of properties on the model.

The continue button makes an ajax call to the controller, and the model binder binds it appropriately to the appropriate sections of the model. The section is refreshed appropriately.

Finally, I would like to have a save button at the bottom of the page that takes all the forms, and binds all of the forms to the model. The model, at this point has all of the properties filled out, and can be processed accordingly.

Can I accomplish this by some ASP MVC magic?

A: 

I would do it the other way round: For the sections use jquery to only submit the elements of the section. You already use ajax here. It might not be a big deal to filter the elements to post.

This way the save action would not require extra work.

You are also able to have ths working without javascript. It needs more work for the continue actions, but at least its posssible. There is no chance to get this working without javascript with multiple forms for the save action.

Malcolm Frexner
A: 

ASP.NET MVC Futures contains nice helper method that allows you to serialize the model into a hidden field that can be fetched in the next controller action that the form is being posted to. This allows a WebForms ViewState imitation.

Darin Dimitrov