How to add tool tip for Dropdownlist Item in

In this post i am going to show you how to add tool tip for dropdownlist item in

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ToolTip_DropDownList.aspx.cs"
    Inherits="ToolTip_DropDownList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:DropDownList ID="ddlDemo" runat="server">
            <asp:ListItem Text="" Value="ASP.NET, the next version of ASP, is a programming framework used to create enterprise-class Web Applications" />
            <asp:ListItem Text="C#" Value="C# (pronounced C-sharp) is an object-oriented programming language from Microsoft" />

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ToolTip_DropDownList: System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

        //Check it is postback or not.
        if (!IsPostBack)

    /// <summary>
    /// Use of this function is to bind title attribute
    /// to each element of ListControl.
    /// </summary>
    /// <param name="list"></param>
    private void BindToolTip(ListControl list)
        foreach (ListItem item in list.Items)
            item.Attributes.Add("title", item.Value);


See here the {{demo}}

1 comment: