0

right now I have a checkbox that looks like this

<input type="checkbox" id="all@(part.ID)" class="part-class" data-partId="@(part.ID)" checked>

But it would be beneficial to me to instead convert this checkbox into a CheckBoxFor, so this is what I tried

@Html.CheckBoxFor(x => x.Parts[i].MoveAll, new { @id = all@"(part.ID)", @class="part-class", data-partId="@(part.ID)" })

But there are red line errors under id and data-partId attributes so how I'm confused on how to apply the same attributes to the checkboxFor?

1 Answers1

1

I changed the html attribute data-partId to data_partId. You can refer the link. And also modified the dynamic id part.

@Html.CheckBoxFor(x => x.Parts[i].MoveAll, new { @id = "all" + "@part.ID", @class = "part-class", data_partId = "@part.ID" })