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

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

    Use Contains, it will work with the two possible post values: "false" or "true,false".

    bool isChecked = Request.Form["foo"].Contains("true");
    

提交回复
热议问题