foreach (var m in Model.Roles.ToList())
{
<div>
@Html.Label(m.Id, m.Name)
@Html.CheckBox(m.Id, m.Selected, new {id = @m.Id })
</div>
}
Where Model.Roles.ToList contains
Id: "5ef15ae7-7e34-4736-98cd-8c472f41869f", Name: "Administrators", Selected: false
Id: "c11fa932-282a-4273-9cc4-ab181aca5d7a" Name: "Users", Selected: true
Id: "c16f8cad-bc32-4539-b2e7-ad82726946b6" Name: "Developers", Selected: false
and the following output is generated:
<div>
<label for="">Administrators</label>
<input id="5ef15ae7-7e34-4736-98cd-8c472f41869f" name="5ef15ae7-7e34-4736-98cd-8c472f41869f" type="checkbox" value="true" /><input name="5ef15ae7-7e34-4736-98cd-8c472f41869f" type="hidden" value="false" />
</div>
<div>
<label for="c11fa932-282a-4273-9cc4-ab181aca5d7a">Users</label>
<input checked="checked" id="c11fa932-282a-4273-9cc4-ab181aca5d7a" name="c11fa932-282a-4273-9cc4-ab181aca5d7a" type="checkbox" value="true" /><input name="c11fa932-282a-4273-9cc4-ab181aca5d7a" type="hidden" value="false" />
</div>
<div>
<label for="c16f8cad-bc32-4539-b2e7-ad82726946b6">Developers</label>
<input id="c16f8cad-bc32-4539-b2e7-ad82726946b6" name="c16f8cad-bc32-4539-b2e7-ad82726946b6" type="checkbox" value="true" /><input name="c16f8cad-bc32-4539-b2e7-ad82726946b6" type="hidden" value="false" />
</div>
You will notice the first label for="" has no value, but when I run the debugger there is a value for this property. Any ideas as to what is happening?
UPDATE: The actual problem appears to be the first id starting with "5". If I replace that with a character, everything works as expected. Odd bug. I wish I knew where to report this.