About the author

The author is just another obsessive compulsive hacker (the good kind) who when confronted with anything new can't help but wonder "how'd they do that?!?"

By day, I'm the Software Architect for CBMC; by night, I just try to "keep the clients happy" as Director of Technology for sdgInteractive.


MCPD

RSS Feed

RadioButton GroupName Insanity

by hilkiah 13. July 2009 15:03

OK, this is hands down one of the craziest things I’ve seen in a while. When dynamically creating RadioButtons for a registration form, I discovered that even if the GroupName was set correctly, the group would not behave as expected and keep the selections unique. After a very short search, it became obvious that this is known bug (SINCE FRAMEWORK VERSION 1.0) that is caused by creating the controls inside of a databound templated control like Repeater or DataList.

It seems like most of the recommendations are to just RadioButtonList instead of individual controls, but that wasn’t an option in my scenario because of the dynamic nature of the control types. Luckily, I found a very helpful article from Jose Guay Paz based on a solution by Erick Smith over on CodeGuru.com. Long story short, you can use a bit regular expressions and JavaScript to trick radio buttons into behaving as expected. (To save the world the repetition, I won’t copy and past the solution here – either of the above articles have great explanations.)

This little trick seems to work just fine – it just blows my mind that it’s even necessary!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

.NET | Web Development