I am trying to solve the following problem.
Lets say you have the the following code in your view
@foreach (var x in Model)
{
<input type="checkbox" name="IDs" value="@x.ID" />
}
The user then makes bunch of selections clicks some link. How do pass the the ids of the selected check boxes to the controller.
e.g you have the following link
@Html.ActionLink("Do Something", "ActionName", new { selection = ???? // i dont know how i reference the checke boxes })
I know I can put the loop in a Html begin form and make the link a submit button but this is an abstract of the problem i am trying to solve. In the actual application i cannot convert the link to button.
I would prefer not to use JavaScript if possible.
I do not know that there is a way to do this with typical MVC helpers. What I have done in the past is created the link so that it’s onclick called a custom jquery function that would select all of the inputs with type checkbox who are selected, and then create a list to be sent back.
Something like this: