0

If have a filter form with multiple filter control inside like first name, last name, birth date, database name etc. Some of them need to be wrap into a control and reuse in the future, so I have something like:

@model FilterViewModel
<form ....>
@Html.Partial("FirstNameLastName", model.FirstNameLastNameFilterViewModel)
@Html.Partial("BirthDate", model.BirthDateFilterViewModel)
<input >//submit form
</form>

The partial views "FirstNameLastName" and "BirthDate" have it's UI and view model. I am wondering when I click submit, will my MVC controller function get all the fields in those partial views and make them into a FilterViewModel object with FirstNameLastNameFilterViewModel and BirthDateFilterViewModel filled?

If not, do you knows how to do it or any other good way to make it works with clean code.

Thanks

Frank
  • 7,235
  • 9
  • 46
  • 56

1 Answers1

0

OK. I admitted I am lazy before asking this quesion. After an experiment with MVC3, I found this supported by default. You just need to make your ViewModel into levels and use it on UI in the same structure, it works perfect.

Thanks.

Frank
  • 7,235
  • 9
  • 46
  • 56