MikeC
MikeC

Reputation: 228

Issue Defining ToolTips on ASP.NET DropDownList items

I am trying to use the “title” attribute for ASP.NET DropDownList items to display mouseover tooltips for each item. However, it seems like after I make a choice, and reopen the list, only tooltips for the selected item and below show the tooltips. For example, if I have 10 items in my list, and choose the 7th one, only 7-10 show tooltips if I re-open the list.

I have done a View Source of the page in the browser, and all the “title” attributes are present, but the upper ones don’t display on mouseover.

If I select the top item in the list, then they all display again. But if I choose the bottom item in the list, only that item has a tooltip that comes up.

I have tried both defining a derived class from DropDownList and overriding the SaveViewState and LoadViewState, as well as re-adding the attribute on a postback; both show the same behavior.

Upvotes: 0

Views: 322

Answers (1)

Ramzz
Ramzz

Reputation: 11

You may use the below to make the selected item go to top of the list and all other items will appear below.

protected void Page_PreRender(object sender, EventArgs e) { var itemIndex = DropDownList1.SelectedIndex; if (itemIndex != -1) { var item = DropDownList1.Items[itemIndex]; DropDownList1.Items.RemoveAt(itemIndex); DropDownList1.Items.Insert(0, new ListItem(item.Text, item.Value)); } }

Upvotes: 1

Related Questions