The following code for onmouseover for the div, not showing tooltip when I first move mouse over the div element, but if I click somewhere and bring the mouse and it shows tooltip. Not sure i'm doing anything incorrectly? is there proper way to show tooltip for READ ONLY dropdownlist inside the div?

enter image description here

DropDown.ascx

<div style="z-index:99;position:relative;padding:1px;" onmouseover="this.title=<%= ddl.ClientID %>.options[<%= ddl.ClientID %>.selectedIndex].text">
    <asp:DropDownList ID="ddl" runat="server" CssClass="etms-dropdown-width" style="position:relative;z-index:-1;">
    </asp:DropDownList>
</div>

DropDown.ascx.cs

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           ....                
          this.ddl.Attributes["onmouseover"] = "this.title=this.options[this.selectedIndex].text";
          foreach (ListItem item in this.ddl.Items)
          {
             item.Attributes["title"] = item.Text;
          }
          this.ddl.DataBind();
        }

        else
        {
            this.ddl.Attributes["onmouseover"] = "this.title=this.options[this.selectedIndex].text";
            foreach (ListItem item in this.ddl.Items)
            {
                item.Attributes["title"] = item.Text;
            }
        }
    }

Related posts

Recent Viewed