Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Show tooltip in Asp.net Dropdownlist items Mouseover Event in C#, VB.NET

Oct 10, 2012
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.

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


Bind or add tooltip for dropdownlist items in asp.net  

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.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

4 comments :

Irfan said...

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

Anonymous said...

my dropdownlist object doesnot showing DataToolTipField property

Anonymous said...

require month and year using dropdownlist in gridview
pls reply me

udham Singh said...

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...

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.