Search code examples
asp.net-mvcrazorcheckboxfor

Checkbox and Hidden field in ASP.NET MVC


Html.CheckboxFor generates hidden field with false value and it is reasonable. But now I need to implement form with GET HTTP method. Obviously true AND false values are being sent to the server when I submit my form. the problem is that MVC model binder cannot understand "true,false" value.

The parameter conversion from type 'System.String' to type 'System.Boolean' failed. 
See the inner exception for more information.

How can I workaround this issue?


Solution

  • Actually the problem was in MvcContribGrid.

    See question: MvcContrib grid and checkboxes

    It combines query string values http://contoso.com?CheckBoxVal=true,CheckBoxVal=false into http://contoso.com?CheckBoxVal=true,false