c# - Trouble using model properties of ViewModel in my controller -
i created viewmodel has 2 of models properties:
public class viewmodel { public login loginvm; public person personvm; }
the properties of login , person objects populated in view user input, when send viewmodel controller , try use person/login properties, says returned null:
[httppost] public actionresult addperson(viewmodel vm) { database da = new database(); da.addlogin(vm.loginvm); da.addperson(vm.personvm); }
both vm.loginvm , vm.personvm null reason.
i found blogpost seemed have come across problem: https://garfbradazweb.wordpress.com/2012/03/08/mvc3-viewmodel-binding-to-controllerpost-methods/
but didn't seem @ all
your ajax call should this:
var model = {loginvm:{your object}, personvm:{your object}}; $.post(url,{vm:model});
Comments
Post a Comment