Web Design

Using and grouping RadioButton Controls in a Repeater

By default, you cannot group radiobutton controls within a repeater as the repeater mangles the names. I had this exact problem when changing from checkboxes to radio buttons – after searching Google for 10 mins, I found a post at the following site by Eric Smith which i’ll copy the relevant info here so I don’t lose it

http://www.codeguru.com/csharp/csharp/cs_controls/custom/article.php/c12371/

Add the following Javascript code to your page:

function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
}

Now for the repeater itself,

The code is linked to the Repeater through the ItemDataBound event. For it to work properly, you need to know the name of the Repeater control, as well as the GroupName you’re assigning to the RadioButtons. In this case, I’m using rptPortfolios as the name of the Repeater, and Portfolios as the group name:

protected void rptPortfolios_ItemDataBound(object sender,
                                           RepeaterItemEventArgs e)
{
   if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType
      != ListItemType.AlternatingItem)
      return;

   RadioButton rdo = (RadioButton)e.Item.FindControl("rdoSelected");
   string script =
      "SetUniqueRadioButton('rptPortfolios.*Portfolios',this)";
   rdo.Attributes.Add("onclick", script);

}

Firefox 3.0 is Europe’s most popular browser | News | TechRadar UK

Firefox 3.0 is officially the most popular web browser in Europe, according to StatCounter’s latest statistics.

Although Mozilla’s browser lags behind Microsoft’s Internet Explorer if you add all of the latter’s different versions together, FireFox has finally pipped IE7 as the most used individual browser version – with 35.05 per cent of the market, according to the data.

Firefox, benefiting from the fact that it doesn’t have the same problem with ‘legacy’ users who stay on older versions of the browser and the arrival of IE8 which is prising people away from IE7.

Not much in it

The gap is currently just over half of a percentage point, and StatCounter CEO Aodhen Cullen believes that it will overtake IE’s complete range shortly.

“The move is partly explained by a small switch from IE 7.0 usage to IE 8.0 but also by growing market share overall by Firefox 3.0,” said Cullen.

“The data shows that Firefox is closing the gap and is now just 10% behind all IE versions in Europe.”

Apparently StatCounter analyse four billion pageloads per month, but it should be pointed out that other major website traffic monitoring companies come up with different figures.

By Patrick Goss

via Firefox 3.0 is Europe’s most popular browser | News | TechRadar UK.