1

I need to do clickable checkboxes using HTML helpers. I've written this code without any problems:

var checkBox = "<label><input type='checkbox' name='vacationTypes' data-id = '"
    + data.checkboxList[i].Id + "' value = '"
    + data.checkboxList[i].Id
    + "' id='Edit-document-checkbox"
    + data.checkboxList[i].Id + "'/>"
    + data.checkboxList[i].Type + "</label>" + "<br/>";

All works fine. But now I need to do like this with html helpers. This is my code:

@for (int i = 0; i < Model.Count(); i++)
{
    <div class="col-md-4">
        @Html.HiddenFor(x => x[i].Id)
        @Html.CheckBoxFor(x => x[i].IsSelected) @Html.LabelFor(x=>x[i].IsSelected, Model[i].Type)
    </div>
}

How can I implement it?

Zabavsky
  • 13,340
  • 8
  • 54
  • 79
Alexander
  • 691
  • 1
  • 11
  • 29
  • 2
    Do you simply need the ` – dom May 25 '15 at 13:56
  • I need to do clickable checkbox lables. http://stackoverflow.com/questions/6293588/how-to-create-an-html-checkbox-with-a-clickable-label – Alexander May 25 '15 at 13:59
  • 2
    I assume by clickable you mean having the checkbox react to the label text being clicked? Wrapping the checkbox with the label does exactly that... – dom May 25 '15 at 14:00
  • 1
    @Dom that should be an answer not a comment – jcuenod May 25 '15 at 14:13

0 Answers0