Html.CheckBox Specify Class

2019-07-05 16:07发布

问题:

How do we specify the class of Html.CheckBox ?

I am trying something like this, but this doesn't work.

   @Html.CheckBox("chk_", abc.IsChecked, new { @class="checkbox" })

THanks !!

回答1:

When specifying class, compiler puts a check to confirm that the bool value is not nullable, i fixed the datatype from null-able bool to bool, and it ran fine.

@Html.CheckBox("chk_", abc.IsChecked, new { @class="checkbox" })