0

My question may be a duplicate of this question. But, I don't get the returned values from the view into my controller.

As defined in the link, I have a model defined for the values that are returned.

But the difference is that, I am not using the AJAX call for this. I get the values of a row, turned into an Array of values by using this stmt:

    var arrayOf = $(currentSelected).get(0);
    var partialView = ('@Url.Action("PartialView")' + '/' + arrayOf);

here partialView correctly points to my controller method and control passes there.

but, my array there (in the controller) is always showing null in spite of correct values in 'arrayOf' and that I am not able to further proceed.

Here is my controller:

     public ActionResult PartialView(ChildColumns[] arrayOf) /*arrayOf is always null, WHY*/
    {
        //stmts
        return PartialView("ChildPartialView");
    }

Here ChildColumns is the model that has all the related fields.

Community
  • 1
  • 1
user2771399
  • 135
  • 1
  • 4
  • 15
  • The razor code would execute *first* on the server, and then pass that information to your page where the javascript would execute. It sounds like you need to use Ajax, if you are indeed wanting to pass the javascript array to your partial view, otherwise, the partialview executes first. – CM Kanode Dec 16 '13 at 14:35

1 Answers1

1

I would use an ajax call for this as mentioned by CM Kanode. something like

$.ajax({
    url: "@(Url.Action("PartialView", "Controller")",
    type: "POST",
    data: arrayOf
    cache: false,
    async: true,
    success: function (result) {
        $(".divContent").html(result);
    }
});
Matt Bodily
  • 6,403
  • 4
  • 29
  • 48