Model binding difficulty

Posted by user281180 on Stack Overflow See other posts from Stack Overflow or by user281180
Published on 2010-06-10T07:35:01Z Indexed on 2010/06/10 20:02 UTC
Read the original article Hit count: 214

Filed under:
|

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");
        }

....

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about mvc