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

后端 未结 11 1874
猫巷女王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:43

    when the check box is checked and submitted perform this

    if ($('[name="foo"]:checked').length > 0)
        $('[name="foo"]:hidden').val(true);
    

    Refer

提交回复
热议问题