[英]How to change the background color of the tooltip for a control available inside gridview on hover
I have a linkbutton
control inside gridview itemtemplate
. 我在
gridview itemtemplate
内部有一个linkbutton
控件。
i want to customize the default tooltip
view of that linkbutton
control. 我想自定义该
linkbutton
控件的默认tooltip
视图。 How can i achieve this ? 我怎样才能做到这一点? Here is my Grid and already it is binded data from another function.
这是我的网格,它已经是来自另一个函数的绑定数据。
<asp:GridView ID="GridReports" runat="server"
OnRowDataBound="GridReports_RowDataBound"
DataKeyNames="SubmitID" ShowFooter="true"
AutoGenerateColumns="false">
<asp:TemplateField>
<HeaderTemplate>Department Lead</HeaderTemplate>
<HeaderStyle CssClass="HeaderStyleWidth100" />
<ItemTemplate>
<asp:HiddenField ID="LabelDepartmentLead"
Value='<%#DataBinder.Eval(Container.DataItem, "DepartmentLead")%>'
runat="server" />
<asp:LinkButton ID="LinkButtonView" Text="View"
Font-Underline="false" Font-Bold="true" ForeColor="Blue"
runat="server"></asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" CssClass="EditItemStyle" />
</asp:TemplateField>
</asp:GridView>
And here is my DataBound where i am assigning the tooltip for the LinkButton control (which is the default tooltip style). 这是我的DataBound,我在其中为LinkButton控件分配工具提示(这是默认的工具提示样式)。
protected void GridReports_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.DataItem != null)
{
HiddenField LabelDepartmentLead =
(HiddenField)e.Row.FindControl("LabelDepartmentLead");
LinkButton LinkButtonView =
(LinkButton)e.Row.FindControl("LinkButtonView");
if (LabelDepartmentLead.Value == string.Empty)
{
LabelDepartmentLead.Value = "No Department Leads";
}
LinkButtonView.ToolTip = LabelDepartmentLead.Value;
}
}
How can i identify the tooltip style and customize it. 我如何确定工具提示样式并对其进行自定义。 Please help!
请帮忙!
Yes Combining Javascript and CSS i am able to achieve this.Code behind remains same as defined in the question. 是的,我可以将Javascript和CSS结合使用。后面的代码与问题中定义的相同。
Posting here - might be helpful for others. 在此处发布-对其他人可能会有帮助。
ItemTemplate ItemTemplate中
<ItemTemplate>
<asp:HiddenField ID="LabelDepartmentLead"
Value='<%#DataBinder.Eval(Container.DataItem, "DepartmentLead")%>'
runat="server" />
<asp:LinkButton ID="LinkButtonView" Text="View" Font-Underline="false"
Font-Bold="true" ForeColor="Blue" runat="server"
onmouseover="showTooltip(this)" ToolTip="Test"
onmouseout="hideTooltip(this)"></asp:LinkButton>
</ItemTemplate>
javascript JavaScript的
<script type="text/javascript">
function showTooltip(control) {
var ttext = control.title;
var tt = document.createElement('SPAN');
var tnode = document.createTextNode(ttext);
tt.appendChild(tnode);
control.parentNode.insertBefore(tt, control.nextSibling);
tt.className = "tooltipCss";
control.title = "";
}
function hideTooltip(control) {
var ttext = control.nextSibling.childNodes[0].nodeValue;
control.parentNode.removeChild(control.nextSibling);
control.title = ttext;
}
$(function () {
$('[title]').tooltip({
content: function () {
var element = $(this);
return element.attr('title')
}
});
});
</script>
css CSS
<style>
.tooltipCss
{
position: absolute;
border: 1px solid gray;
margin: 1em;
padding: 3px;
background: #A4D162;
font-family: Trebuchet MS;
font-weight: normal;
color: black;
font-size: 11px;
}
</style>
You can use JQuery library. 您可以使用JQuery库。
Click on the view source link : http://jqueryui.com/tooltip/#custom-style 单击查看源链接: http : //jqueryui.com/tooltip/#custom-style
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.