Raihan Iqbal
Life is codetastic!

How to add a tooltip to an ASP.NET DropdownList item

If you want to set a common tooltip for all the items in a DropDownList then you can just set the Title attribute for each item like so:

foreach(ListItem item in ddlScorecards.Items)
    item.Attributes.Add("Title", "YOUR TOOLTIP TEXT");

But if you want to set unique tooltips for each item then you have wrap the text value of the items in a DIV.

foreach(ListItem item in ddlScorecards.Items)
  item.Text = String.Format("<div title='{0}'>{1}</div>", "YOUR_TOOLTIP", item.Text);

Happy Programming!

Share

Posted in Uncategorized | 2,155 views | 1 Comment

One Response to “How to add a tooltip to an ASP.NET DropdownList item”

  1. Hey, nice post, really well written. You should write more about this.

Leave a Reply