« Windows does it yet again - Linux and VMWare comes to the rescue | Main | Filezilla in Linux-land »

March 17, 2007

Microsoft and ASP.NET gang up on radio-boxes

ASP.NET rips a new one for the humble old radio button.

The problem? You can glean absolutely no useful information from them apart form the fact that they are checked or not.

When you use them in static ASP.NET pages the situation is not too bad as you get to define each radio button individually as a control / container. You can then set up events for CheckedChanged or even check directly that the button is checked on a page postback and then undertake some actions based on that fact.

What if you wanted to create the radio buttons programatically from the database and then access something like a table row id from the VALUE of the checked radio button? Seems simple enough, seems reasonable.

It can't be done.

The only information you can access is the Text value of the radio button. In every other control that contains the 'value' of the input. The 'Text' property of a radio button is the text that appears BESIDE the control. wtf? WTF!! The old Visual Basic programming model rears its head with a vengance - you can have consistency as long as you don't expect everything to work the same way!

Note to Microsoft - writing a computer language is not like creating a spoken language - there don't HAVE to be irregular verbs you know!!

What Microsoft forces you to do is to set up something like a hidden input field in the same context / container as the radio button. When you see that the radio button in question is checked you can then grab the data you need from the hidden input field (using FindControl usually...)

Easy? Hmm...

Posted by dottie at March 17, 2007 4:54 PM

Trackback Pings

TrackBack URL for this entry:
http://www.5thpercentile.com/blog/mt-tb.cgi/32

Comments

Post a comment




Remember Me?

(you may use HTML tags for style)