im trying to get the values of all the checked checkboxes and post those values(integer) to an action result, the problem is i get an empty array at the controller side …
my jquery code is as follow:
function getIds() {
var idList = new Array();
var loopCounter = 0;
//find all the checked checkboxes
$("input:checked").each
(
function() {
//fill the array with the values
idList[loopCounter] = $(this).val();
loopCounter += 1;
}
);
//Send the list off
alert(idList);
var postData = { values: idList };
$.post("/Admin/Delete/", postData);
}
my controller side code is following
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Delete(Int32[] values)
{
try
{
// TODO: Add delete logic here
return RedirectToAction("NewSubDashboard");
}
catch
{
return View();
}
}
there is no problem with the posting but im gettin an empty array at the controller side…
i extracted the values from httpcontext as
HttpContext ctx = System.Web.HttpContext.Current;
string[] ValArr = ctx.Request.Params.GetValues(0);