MVC CheckBox returning “true,false”

Have you noticed that if you create a CheckBox in an MVC view like so:


And then check the value of this control in the controller after you have checked it:


You see this instead of “true”:


You can handle this a couple of ways, but I chose to roll with the punches. I receive the value as a string and if the value is “true,false”, then that means true:

string result = Request["SendPassword"].ToString();
bool isChecked = result.Contains("true,false");
if (isChecked) {
 // Stuff


  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: