Unobtrusive validation not working after adding checkboxes to the form in mvc 4

后端 未结 1 888
轻奢々
轻奢々 2021-01-23 05:48

I want to make checkboxes optional, whether to be checked or not. But when I add a checkbox on my view it will make unobtrusive validation to be stopped. But when I remove the c

相关标签:
1条回答
  • 2021-01-23 06:09

    I had exactly this problem & posted a question here. Currently I don't have a solution to the problem, but I did find a workaround. Instead of using Html.CheckBoxFor I used Html.CheckBox like so:

    @Html.CheckBox("Employee.Active")
    

    I gave it the same name as the CheckBoxFor that was created by the razor view. This is now working as I expected but I consider it a workaround rather that a solution, and I have no idea what's actually causing the problem!

    0 讨论(0)
提交回复
热议问题