I am using ASP.NET MVC 3 and I am trying to create a simple json array binding to List<JsonPositions>
. JsonPositions
is a custom object with the same properties as the json objects in the array.
This is what my array looks like on the client:
var widgetPositions = [ { col: 5, row: 1, id: 2 }, { col: 4, row: 5: id: 40 } ]; $.ajax({ url: 'the url', data: { positions: widgetPositions }, success: function () { alert('Save successful.'); }, error: function () { alert('An error occurred while trying to update the widget positions.'); } });
This code works correctly when the request is validated in Chrome.

In the controller, we have the following method of action:
public void UpdatePositions(List<JsonPosition> positions) {
When I look at the widgetPositions
list, it has two elements, like a json array, but the properties of the objects do not match the values ββfrom the objects on the client. This is what the JsonPosition
object looks like:
public class JsonPosition { public int id { get; set; } public int col { get; set; } public int row { get; set; } }

Thanks for any help you can offer :)
source share