I am trying to pass list of int type to Controller on jquery load, but not successfull. Here is my code:
function Addcov() {
var dt = '@ViewBag.dt';
@{
List<int> covtypes = new List<int>();
foreach (var item in ViewBag.CovTypes)
{
covtypes.Add(item);
}
}
alert('@covtypes');
$("#Form").dialog({
autoOpen: true,
width: 1000,
resizable: false,
title: 'Add',
modal: true,
open: function () {
$(this).load(
'../controller/AddAction',
{ fromDate: dt, CovTypes: JSON.stringify('@covtypes') },
function (response, status, xhr) {});
},
buttons: {}
});
}
i can suggest put values of ViewBag [List of int] as csv in html element and later convert them to array of int and pass to controller as