来自数据库和CSS的内容的工具提示

时间:2019-03-25 05:44:35

标签: javascript jquery asp.net tooltip

我有一个容器,其中装有数据库中的图像和文本。在Container上悬停时,我需要显示数据库中的工具提示

ASP.net

 <div class="Imagecontainer" style="float:left; width:100px; text-align:center;">
   <asp:Image ID="InvestorImg" runat="server" src="images\Invs.png"  />
      <br /><br />
      <span style=" font-family:Arial; font-weight:bold; color: black;">Investors</span>
      <br /><br />
       <asp:Label ID="NewAccountsLabel" runat="server"  CssClass="NewAccountsLabel_style" ></asp:Label>      
 </div> 

页面加载我正在调用另一种方法将数据加载到NewAccountsLabel

 private void NewAccounts()
    {
        siteSoapClient site = new siteSoapClient();
        DataSet NewAccountsds1 = site.GetNewAccounts();
        NewAccountsLabel.Text = "New" + "<br/>" + "Accounts :" + NewAccountsds1.Tables[0].Rows[0][0].ToString();

}

在查询中,我有一个日期字段,希望将其显示为CSS的工具提示。我知道如何在不使用CSS的情况下添加工具提示,但是我不知道如何在其中添加CSS

2 个答案:

答案 0 :(得分:0)

$(document).ready(function () {
    $('.Imagecontainer').hover(function () {
        $(this).find('.tooltip').html('<img src="' + 'Put Your Value`enter code here` + '" alt="loading...">').fadeIn();
    }, function () {
        $(this).find('.tooltip').hide();
    }).append('<span class="tooltip"></span>');
});

答案 1 :(得分:0)

为div标签添加ID

<div class="Imagecontainer" id="DivID" runat="server" style="float:left; width:100px; text-align:center;"> <asp:Image ID="InvestorImg" runat="server" src="images\Invs.png" /> <br /><br /> <span style=" font-family:Arial; font-weight:bold; color: black;">Investors</span> <br /><br /> <asp:Label ID="NewAccountsLabel" runat="server" CssClass="NewAccountsLabel_style" ></asp:Label>
</div>

然后在后端代码中,使用DivID.Attributes.Add(“ title”,“您的数据库中的文本”);

private void NewAccounts()
{
    siteSoapClient site = new siteSoapClient();
    DataSet NewAccountsds1 = site.GetNewAccounts();
    NewAccountsLabel.Text = "New" + "<br/>" + "Accounts :" + 
        NewAccountsds1.Tables[0].Rows[0][0].ToString();
DivID.Attributes.Add("title", "Your Text From Database");

}
相关问题