Checkbox not working with boolean viewmodel property

后端 未结 4 1098
半阙折子戏
半阙折子戏 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:46

    After letting Visual Studio generate the form based on my ViewModel here is how it does it:

            

    Additionally, I was missing the closing of my input tag. So it can also be done like this which is the bootstrap preferred way:

    
    

提交回复
热议问题