Fernando
Fernando

Reputation: 4028

EditorTemplate as a dynamic form

I have a form that will load some fields when the page is requested and some other fields that will be loaded as the user choses one option in a dropdown. The fields that should be loaded upon selection are EditorTemplates. Is there a way I could make it work without the need to refresh the page (i.e a partial view requested via ajax) and keeping the "binding" to my viewmodel?

Upvotes: 0

Views: 478

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

Yes, this is possible as long as you respect the naming conventions of your input fields so that the default model binder can understand them. Here's an example of those conventions for lists. And here's a great article illustrating how you could implement editing a variable length list.

Upvotes: 1

Related Questions