Search code examples
asp.net-mvccheckboxfor

Implement jquery multiswitch in MVC checkboxfor()


So I included this jquery form plugin called multiswitch (credits to the source) in my MVC web project and integrated it using Html.Checkboxfor() in my Create.cshtml and in my model 'IsReserved' bool property. However, it doesn't bind well in my model when I click the submit button and call the Http post of my controller. Refer to screenshots and public repo link below:

https://github.com/ricsierics/Multiswitch-Demo

View codeUser InterfaceModelController


Solution

  • Surprisingly, I can now bind the multiswitch to my model well by adding or removing the 'checked' attribute. See screenshots below. Done also committing changes on the said repo link.

    jquery function

    debugging