@Code Html.RenderPartial("Address", Model.MyAddressViewModel) End Code
The problem is that this doesn't bind back to the parent model when the parent form is submitted. Use the Editor helper instead:
@Html.EditorFor(function(m) m.MyAddressViewModel)
Now this will bind. However, the resulting html looks like crap. You can either decorate the crap out of your view model, or just make a custom editor template. All you have to do is make a new folder called EditorTemplates in the Shared folder of your MVC project. Then put the partial view in this folder. Make sure you name the view the same as the data type of the object your are creating the editor for. For example, AddressViewModel.vbhtml.
No comments:
Post a Comment