I need to put the same NAME tag for Html.CheckBox somehow .
How I can do it? Here is my code… Thank you!
foreach (var answer in @question.Answers)
{
@Html.CheckBox("answer_CheckBox_" + answer.ID.ToString(), false, new { Value = answer.ID });
<label style="margin-left: 0.5em;">@answer.Title</label>
<br />
}
You’re using an incrementing value as part of the
nameargument to theCheckBox()method (the first argument), so naturally they’re going to be different names in the rendered HTML.If you need them all to have the same
nameattribute value, use a static value: