Introduction:
Here I will explain how to show tooltip in dropdownlist items on mouseover event in asp.net using C# and VB.NET.
Description:
In previous posts I explained Bind data to Dropdownlist from database, Bind Images to dropdownlist, Cascading dropdownlist example and many articles relating to dropdownlist, JQuery, asp.net etc. Now I will explain how to show tooltip in dropdownlist items on mouseover event in asp.net.
In previous posts I explained Bind data to Dropdownlist from database, Bind Images to dropdownlist, Cascading dropdownlist example and many articles relating to dropdownlist, JQuery, asp.net etc. Now I will explain how to show tooltip in dropdownlist items on mouseover event in asp.net.
To
show tooltip in dropdownlist items on mousover we need to write the codesnippet like as shown below
Show
tooltip in dropdownlist items mouseover event
C# Code
protected void ddlDetails_DataBound(object
sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
if(ddl!=null)
{
foreach (ListItem li in
ddl.Items)
{
li.Attributes["title"] = li.Text;
}
}
}
|
VB.NET
Protected Sub ddlDetails_DataBound(ByVal
sender As Object,
ByVal e As
EventArgs)
Dim ddl As DropDownList = TryCast(sender,
DropDownList)
If ddl IsNot Nothing Then
For Each li As ListItem
In ddl.Items
li.Attributes("title") = li.Text
Next
End If
End Sub
|
If
you want know the complete source code please check below post
|
Above post
will explain clearly how to bind tooltip for dropdownlist items in asp.net
using C# and VB.NET.
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
4 comments :
Wish there was an easier way to do this, such as
ddl.DataValueField = "ID";
ddl.DataTextField = "Text";
ddl.DataToolTipField = "Description"; //this would have been sweet
my dropdownlist object doesnot showing DataToolTipField property
require month and year using dropdownlist in gridview
pls reply me
hi suresh,
i want to show tooltip on mouseover of repeater control in asp.net using javascript.
i am searching for that from last 1 day and still searching.
so please help...
Note: Only a member of this blog may post a comment.