Checkbox not working with boolean viewmodel property

后端 未结 4 1106
半阙折子戏
半阙折子戏 2021-02-12 13:02

I am using MVC6 and have a checkbox input field in my form, but when the form is submitted the value for the checkbox always gets passed to the ViewModel as false:

4条回答
  •  孤街浪徒
    2021-02-12 13:30

    The razor view engine normally creates a checkbox and one hidden input using the same name.

    You can simply use the html below to ensure you get your desired result:

    Include Sales Tax

提交回复
热议问题