Reputation: 1669
i am trying to post a JavaScript object to my MVC controller, however its not binding the nested object.
c# object:
public class OrderHeader
{
public OrderHeader()
{
this.orderAddress = new OrderAddress();
}
public int SubTotal{ get; set; }
public string OrderNumber { get; set; }
public OrderAddress orderAddress;
}
public class OrderAddress
{
public OrderAddress()
{
}
public int id { get; set; }
public int OrderID { get; set; }
public string BillToFName { get; set; }
}
js object:
{ OrderNumber: "KM123", SubTotal: "10", orderAddress: { BillToFName: "street 2" } }
I can read orderNumber and SubTotal perfectly fine within my controler, however BillToFName is NOT binding.
Upvotes: 0
Views: 310
Reputation: 9508
Try adding a getter and setter to your property:
public OrderAddress orderAddress { get; set; }
Upvotes: 1