July 17 2008

ASP.Net RadioButton control is teh sux0r

RadioButtonList controls are great as long as you don’t want any custom formatting or additional controls in your list.  I like to avoid using the native HtmlControls controls (like HtmlInputRadioButton) as I feel if you’re going to use an Html control, you might as well use the “bells and whistles version” (unless the WebControl control isn’t accessiblility friendly).

In the case of System.Web.UI.WebControls.RadioButton this is wrong. Dead wrong.  It is almost certainly the worst WebControl control Microsoft has made.

It screws up with:

  1. GroupName - the property doesn’t work (known bug Q316495 / 316495).  See this post I wrote.
  2. Value - There doesn’t seem to be a way to set the value of the input control part.  It seems to take the ID as the value, which is not very useful if you want to have a numeric value.

So my advice is:  Use a RadioButtonList control where you need to do straight lists, and if you need a custom layout radio button list, use the HtmlInputRadioButton.  Avoid the RadioButton control at all costs

Comments (View)
blog comments powered by Disqus

Please...

Leave a comment if this has helped or offended you.

StackOverflow Id