I have a view, which simply does a foreach loop on a IEnumerable passed in the viewmodel, I have a way for people to select these entities on the list (apply a class to them to highlight), and this currently works for some clientside printing through jquery. Is there a way I can get these entities (staff) which have the highlight class and push them back as a model to the controller?
I have tried to use html.hiddenfor and just putting all the staff in there and making a form, with asp-action of my function on the controller and just a submit button, this did not work
the controller contains
public IActionResult StaffSelectionAction(StaffIndexModel model)
{
//things to do to process the selected staff
foreach (Staff staff in model.staff){
//Do stuff
}
return RedirectToAction("Index");
}
the view contains
<form asp-action="StaffSelectionAction">
@Html.HiddenFor(b => b.staff)
<input type="submit" value="Process Staff" class="btn btn-default" asp-action="StaffSelectionAction"/>
</form>
model contains
public IEnumerable<Staff> staff { get; set; }
Edit: spelling mistake in code