asp.net mvc: why is Html.CheckBox generating an additional hidden input

后端 未结 11 2064
猫巷女王i
猫巷女王i 2020-11-22 13:59

I just noticed that Html.CheckBox(\"foo\") generates 2 inputs instead of one, anybody knows why is this so ?



        
11条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 14:46

    This is not a bug! It adds the possibility of having always a value, after posting the form to the server. If you want to deal with checkbox input fields with jQuery, use the prop method (pass the 'checked' property as the parameter). Example: $('#id').prop('checked')

提交回复
热议问题