在asp.net中可以在下拉菜单中显示工具提示吗?

Is It possible to show tooltip on dropdown in asp.net

本文关键字:工具提示 显示 asp net 下拉菜单      更新时间:2023-09-26

在我的web应用程序中,我有dropdowncheckboxes控件,但我试图在选择框项目上显示工具提示。这是可能的。

I am try code:

. aspx:

<%@ Register Namespace="Saplin.Controls" Assembly="DropDownCheckBoxes" TagPrefix="asp"  %>
    <link rel="stylesheet" href="css/bootstrap-3.1.1.min.css" type="text/css" />
     <link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet" />
     <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
     <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>  
    script tag
      <script>
             $(function () {
                 $("#tooltip1").tooltip();
             });
          </script>
        <div class="tooltip1"> <asp:DropDownCheckBoxes ID="dropdown1" runat="server" UseSelectAllNode="true" UseButtons="true" OnSelectedIndexChanged="dropdown1_SelectedIndexChanged"
                                AutoPostBack="true"> <Style SelectBoxWidth="200" DropDownBoxBoxWidth="200" DropDownBoxBoxHeight="130" />
                        <Texts SelectBoxCaption="" />  
                                                 </asp:DropDownCheckBoxes> <asp:Label runat="server" ID="tooltip1"></asp:Label>

cs:

protected void Page_Load(object sender, EventArgs e)
        {
            tooltip1.Text = dropdown1.Texts.SelectBoxCaption;
}
 protected void dropdown1_SelectedIndexChanged(object sender, EventArgs e)
        {
            List<String> checkedList = new List<string>();
            foreach (ListItem item in dropdown1.Items)
            {
                if (item.Selected)
                {
                    checkedList.Add(item.Value);
                }
            }            
            dropdown1.Texts.SelectBoxCaption = String.Join(",", checkedList.ToArray());
}

工具提示不显示,谁能告诉我我在哪里做错了,我不知道。是否有任何事件显示工具提示

图片描述此处

谢谢

为列表添加工具提示

public static void BindTooltip(ListControl lc)
    {
        for (int i = 0; i < lc.Items.Count; i++)
        {
            lc.Items[i].Attributes.Add("title", lc.Items[i].Text);
        }
    }