asp.net mvc - MVC model property passed as null -


i have typed views pass editors several properties eg.

public class bookingmodel {     public firstpropertymodel firstproperty { get; set; }     public secondpropertymodel secondproperty { get; set; }     public thirdpropertymodel thirdproperty { get; set; } }  @model mywebsite.models.bookingmodel @using (html.beginform("order", "booking", formmethod.post, new { @id = "order_summary" })) {     @html.editorfor(model => model.firstproperty, "_firstproperty")     @html.editorfor(model => model.secondproperty, "_secondproperty")     @html.editorfor(model => model.thirdproperty, "_thirdproperty")     <input type="submit" id="btnorder" value="order" /> } 

all properties objects passed action nicely 1 property (first) comes null.

they within editortemplates , views types - use own models.

any idea why happening?

i'd try initializing/instantiating bookingmodel properties in constructor see if helps

public class bookingmodel {     public bookingmodel()     {         firstproperty = new firstpropertymodel();         secondproperty = new secondpropertymodel();         thirdproperty = new thirdpropertymodel();     }     public firstpropertymodel firstproperty { get; set; }     public secondpropertymodel secondproperty { get; set; }     public thirdpropertymodel thirdproperty { get; set; } } 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -