Asp .net mvc 3 CheckBoxFor method outputs hidden field, that hidden field value is false when checkbox is disabled with selected true

后端 未结 4 1990
温柔的废话
温柔的废话 2020-12-16 19:28

CheckBoxFor(t => t.boolValue, new { disabled=\"disabled\" }) method to render a checkbox, in disabled mode.

The method renders a hidden field as well.

My que

4条回答
  •  清歌不尽
    2020-12-16 19:40

    Here is a quick tip I discovered : If you set a default value for the boolean value on the object. It's possible to write out the tag with the value as true/false (this value should be the opposite of the default boolean value on the object)

    
    

    The value is only sent if the checkbox is checked, so it works.

提交回复
热议问题