How to get the checked checkbox from a ASP.NET MVC2 form -


I have a hard time in ASP.NET MVC2 that is trying to get checked values ​​of different checkboxes .

Here is my view

  & lt; Div id = "roleselection" & gt; & Lt; Ul & gt; & Lt;% foreach (roles in the model. Roles) {%> & Lt; Li & gt; & Lt; Input type = "checkbox" name = "roles" value = "& lt;%: roles%>" / & Gt; & Lt;%: Roles% & gt; & Lt; / Li & gt; & Lt;%}% & gt; & Lt; / Ul & gt; & Lt; / Div & gt;  

My model:

So basically I'm trying to figure out how to get all the check boxes from my form!

Thanks

id instead of the attribute id < / Code> should be unique among all elements.

The name attribute in your case will allow you to reconstruct multiple checkboxes in a single group. / P>

 < Code> & lt ; Input type = "checkbox" name = "roles" value = "& lt;%: roles%>" / & gt; & lt;%: roles% & gt;  

Comments