I am having a model and I am using ajax.post. I can see that the model binding isn`t being done for the arraylists in my model, though binding done for the properties of int or string type. Why is that so? My code is as below.
I have a model with the following properties
public class ProjectModel
{
public int ID { get; set; }
public ArrayList Boys= new ArrayList();
}
In my view I have
$(document).ready(function () {
var project = new Object();
var Boys= new Array();
var ID;
.......
ID = $('#ID').val();
project.Boys= Boys;
.....
$.ajax({
type: "POST",
url: '<%=Url.Action("Create","Project") %>',
data: JSON.stringify(project),
contentType: "application/json; charset=utf-8",
dataType: "html",
success: function () {
},
error: function (request, status, error) {
}
});
//
My controller
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(ProjectModel project)
{
try
{
project.CreateProject();
return RedirectToAction("Index");
}
....