tags:

views:

44

answers:

1

My FormCollection is returning back a Checkbox, but I am after the value

collection["SelectedCheckbox"]

this returns "true,false"

but I want the results, which should be either true or false

+2  A: 

in asp.net-mvc you would have to check for false, the reason you check for false because the Html Checkbox helper does some kind of freaky thing for value true

True returns as:

it makes the string read "true, false"

so you may have thought it was two values but its just one and means true

False returns as:

it makes the string read "false"

TStamper
Refer to similar question for more detail: http://stackoverflow.com/questions/658458/mvc-html-checkbox-and-form-submit-issue/658514#658514
TStamper
if you specify `bool` as parameter instead of reading it as a `string` then it work as expected
TStamper