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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -