In my app i need to pass some object from view to another controller. Everything work fine for me but table which is part of this object is always null, even if it is populate proper in view. Let me show the code:
The view :
var loadNumber = @(Html.Raw(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(Model.LoadNumber)));
var data = @(Html.Raw(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(Model.Stops)));
var url = '@Url.Action("ReportViewer","LoadReport")';
var criteria = {LoadNumber: loadNumber,Stops: []};
for (var i = 0; i <= selected.length - 1; i++) {
var id = selected[i].cells[1].innerText;
for (var j = data.length - 1; j >= 0 ; j--) {
if (data[j].StopmstSequence == id) {
criteria.Stops.push(data[j].StopID);
break;
}
}
}
window.open($.param.querystring(url, criteria));
In this part everything looks ok. Criteria object is populated well.
Controller :
public ActionResult ReportViewer(Criteria criteria)
{
return View();
}
Of course this controler is much bigger but i can't show rest of code ( criteria object is most important )
Criteria Class :
public class Criteria
{
public string LoadNumber { get; set; }
public string[] Stops { get; set; }
}
Now after run code in View the Criteria
object in controller have LoadNumer
set proper but Stops
is always null
. I try to change from string[]
to List<string>
or even IEnumerable<string>
but always have same result. Can some one know why ?