Home > ASP.Net, Uncategorized > Add ToolTip for DropDownList Items in ASP.Net

Add ToolTip for DropDownList Items in ASP.Net


Hi all,

Try this example to Add ToolTip for DropDownList Items in ASP.Net

<asp:DropDownList ID="DropDownList1" runat="server" ondatabound="DropDownList1_DataBound">
</asp:DropDownList>

In Code behind :

protected void DropDownList1_DataBound(object sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
if (ddl != null)
{
foreach (ListItem li in ddl.Items)
{
li.Attributes["title"] = li.Text; // setting text value of item as tooltip
}
}
}

Hope this helps

Good Luck

Advertisements
Categories: ASP.Net, Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: