Tooltips on ASP.NET RadioButtonList items

by Brad 6. June 2007 11:04
It's easy to set the tooltip on a RadioButtonList control, but what if you want to set a different tooltip for each of the individual radio buttons? (actually ListItems as far as .NET is concerned).

Well its fairly simple, but undocumented, take this example which will set the text of each item to be it's tooltip:

  List<string> ds = new List<string>();
 ds.Add("Radio 1");
 ds.Add("Radio 2");
 ds.Add("Radio 3");

 RadioButtonList rbList = new RadioButtonList();

 rbList.DataSource = ds;
 rbList.DataBind();

 foreach (ListItem item in rbList.Items)
 {
     item.Attributes.Add("Title", item.Text);
 }


And this approach will work for anything, for example you might want to add an OnClick or mouse over events in the same way.

Tags:

C#

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar