Annoying MVC discovery of the day
-
When you try to retrieve the value of a checkbox on a form using
Request.Form.Get(keyname)
, the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
When you try to retrieve the value of a checkbox on a form using
Request.Form.Get(keyname)
, the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
When you try to retrieve the value of a checkbox on a form using
Request.Form.Get(keyname)
, the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013Schrödinger's Checkbox.
cheers Chris Maunder
-
Wouldn't that be "true,false?"? That's equally absurd so, why the f*ck not, right?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Schrödinger's Checkbox.
cheers Chris Maunder
This is one of the many reasons I despise web development.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Schrödinger's Checkbox.
cheers Chris Maunder
It's almost as if the federal government had a hand in the implementation... It's no wonder the ObamaCare web site is so f*cked up.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
When you try to retrieve the value of a checkbox on a form using
Request.Form.Get(keyname)
, the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
When you try to retrieve the value of a checkbox on a form using
Request.Form.Get(keyname)
, the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013Don't Microsoft checkboxes have three values? 'true', 'false', and 'true,false'? Maybe thats only windows forms.
Jack of all trades, master of none, though often times better than master of one.
-
Don't Microsoft checkboxes have three values? 'true', 'false', and 'true,false'? Maybe thats only windows forms.
Jack of all trades, master of none, though often times better than master of one.
-
Don't Microsoft checkboxes have three values? 'true', 'false', and 'true,false'? Maybe thats only windows forms.
Jack of all trades, master of none, though often times better than master of one.
The only two return values I've seen in MVC are "false", and "true,false". How other bastardized Microsoft frameworks handle it are not applicable.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Don't Microsoft checkboxes have three values? 'true', 'false', and 'true,false'? Maybe thats only windows forms.
Jack of all trades, master of none, though often times better than master of one.
WPF checkboxes have an
IsChecked
property that can be eitherfalse
,true
, ornull
. When you want to check if the checkbox is really checked, you have to:if (checkbox.IsChecked == true)
{
...
}Butt-fugly.
Software Zen:
delete this;
-
WPF checkboxes have an
IsChecked
property that can be eitherfalse
,true
, ornull
. When you want to check if the checkbox is really checked, you have to:if (checkbox.IsChecked == true)
{
...
}Butt-fugly.
Software Zen:
delete this;
Not to get too much into a programming discussion, this is the lounge, but you can also write it this way
if (checkbox?.IsChecked : false)
{
//...
}This way, if it IsChecked is null, it's still false. Leave it to Microsoft to create a system where nothing is something and you still can't divide by zero. :wtf:
if (Object.DividedByZero == true) { Universe.Implode(); }
-
When you try to retrieve the value of a checkbox on a form using
Request.Form.Get(keyname)
, the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013As far as I know, it has (almost) nothing to do with MVC nor Microsoft. This is the data send by the form on the HTML page. If instead of accessing raw values, you would let MVC load the values in a model, then the framework would handle that kind of stuff automatically. If you want to work at low level, then you have to understand the subtilities...
Philippe Mori
-
When you try to retrieve the value of a checkbox on a form using
Request.Form.Get(keyname)
, the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013Nothing to do with MVC...With HTML checkbox value is absolutely meaningless, you should check the 'checked' attribute... If you want to use MVC, use the helpers - they resolves the anomalies of HTML... If you want to use HTML directly...read about it...
Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.
-
When you try to retrieve the value of a checkbox on a form using
Request.Form.Get(keyname)
, the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013It's quite weird, yes, but not an MVC or .NET specific behavior. It'd be the same if you used Ruby or JavaScript. If you use MVC's built-in model binding, they abstract this away from the coder, if not, if you really want to access it via the Form object - a recommended approach is to use GetValues(name)[0].
Regards, Nish
Website: www.voidnish.com Blog: voidnish.wordpress.com
-
Schrödinger's Checkbox.
cheers Chris Maunder
> John Simmons - developing bipolar checkboxes since 1989 :-)
Regards, Nish
Website: www.voidnish.com Blog: voidnish.wordpress.com
-
When you try to retrieve the value of a checkbox on a form using
Request.Form.Get(keyname)
, the resulting value is "false" if the checkbox isn't checked, but if the checkbox IS checked, the returned value is "true,false". WTF?!!!! I mean seriously - WHAT THE F*CK?!!!!!!".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013It's called a "Microsoft Boolean" It has as many values as they like, and there's nothing you can do to stop them changing it to become even more useless
I wanna be a eunuchs developer! Pass me a bread knife!
-
Nothing to do with MVC...With HTML checkbox value is absolutely meaningless, you should check the 'checked' attribute... If you want to use MVC, use the helpers - they resolves the anomalies of HTML... If you want to use HTML directly...read about it...
Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.
I *am* using the helpers, and this has NOTHING to do with whether I'm using them or not. I'm using the standard method for retrieving the checked status from within a view. REGARDLESS of all of that, "true,false" as a return value is severely f*cked up.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
It's quite weird, yes, but not an MVC or .NET specific behavior. It'd be the same if you used Ruby or JavaScript. If you use MVC's built-in model binding, they abstract this away from the coder, if not, if you really want to access it via the Form object - a recommended approach is to use GetValues(name)[0].
Regards, Nish
Website: www.voidnish.com Blog: voidnish.wordpress.com
Did I say it was the fault of .Net or MVC?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
As far as I know, it has (almost) nothing to do with MVC nor Microsoft. This is the data send by the form on the HTML page. If instead of accessing raw values, you would let MVC load the values in a model, then the framework would handle that kind of stuff automatically. If you want to work at low level, then you have to understand the subtilities...
Philippe Mori
Does it LOOK like I don't understand the "subtleties"? Returning "true,false" to indicate that a checkedbox is checked isn't a subtlety, it's f*cked up, or if you're too sensitive to call it what it really is (or you're just playing around, and not working on a real project), it's quirky.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013