c# - How do I serialize one to many object to ASP .NET MVC controller from JQuery -


i have view model, class1, bound view. class1 has model1 class object , model2 list. have in view name element

class1.model1.property1 etc... class1.model2[n].property1 etc... 

when use jquery $('form').serialize() class1 base properties serialized others come null.

any in regard appreciated.

view information:base class -

<div class='col-sm-6'>     @html.textbox("rolemastermodel.applicationname", model.applicationname, new { @disabled = "disabled", @class = "form-control", @maxlength = "500" }) </div> 

model1 rendering -

<div class='col-sm-6'>      @html.hidden("rolemastermodel.rolemodel.roleid", model.rolemodel.roleid)      @html.textbox("rolemastermodel.rolemodel.rolename", model.rolemodel.rolename, new { @class = "form-control", @maxlength = "500" }) </div> 

model2 rendring -

<span>     <input type="checkbox" value="false" id="rolemastermodel.applicationrolepermissionmodels[@html.raw(counter)].canview" @html.raw((rolepermission.canview) ? "checked=\"checked\"" : "") /> view     <input type="hidden" class="associatedhidden" name="rolemastermodel.applicationrolepermissionmodels[@html.raw(counter)].canview" value="false" /> </span> 

you using model1 rendering html helpers

but model2 using normal html ..

make sure elements should come html helpers ..

then values can receive in controllers.


Comments