Dragimi Smehurko
Dragimi Smehurko

Reputation: 61

AJAX to .NET posting of object with nested array

I am trying to POST an object via jQuery AJAX call to .NET controller.

The object I am posting (ACDto) has among its properties a nested array (Keys) of objects

enter image description here

All is well but the nested array has its objects not bound/de-serialized correctly: all properties of the objects from the nested array are wither null, 0 or false. Example:

View:

enter image description here

Controller:

enter image description here

I do console.log() the data before Ajax post and looks good (valid jSON)

What am I missing ? I will appreciate your help!

Upvotes: 0

Views: 218

Answers (1)

Brian Mains
Brian Mains

Reputation: 50728

Try using public properties instead of fields:

public class AcBitDto
{
    public string tag { get; set; }
    public string name { get; set; }
    public boolon { get; set; }
    public bool enabled { get; set; }
}

Fields will not work: Binding public fields with ASP.NET MVC as well as public properties?

Upvotes: 1

Related Questions