I want to test if the checkbox is checked or not from my action method, what i need is to pass checkbox value from view to controller.
This is my view:
If you want your value to be read by MVT controller when you submit the form and you don't what to deal with hidden inputs. What you can do is add value
attribute to your checkbox
and set it to true
or false
.
MVT will not recognize viewModel property myCheckbox
as true here
but will if you add
Script that does it:
$(document).on("click", "[type='checkbox']", function(e) {
if (this.checked) {
$(this).attr("value", "true");
} else {
$(this).attr("value","false");}
});