I'd like to return a list of Personnes from checked checkbox in my view and get it in my controller but selectedObjects count is always 0...
Here's my view with checkboxes:
@using (Html.BeginForm("Presence", "Evenement"))
{
foreach (var p in Model.Personnes)
{
<input type="checkbox" name="selectedObjects" value="@p" />
}
@Html.AntiForgeryToken()
<input type="submit" value="Valider Presence" class="btn btn-primary" />
}
my controller:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Presence(List<Personne> selectedObjects)
{
return View(selectedObjects);
}