如何使用Asp.Net C#在鼠标悬停时突出显示datalist项目 [英] how to highlight datalist item on mouseover using Asp.Net C#
本文介绍了如何使用Asp.Net C#在鼠标悬停时突出显示datalist项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Asp.Net C#在鼠标悬停时突出显示datalist项目。
我看到一篇指定它的文章。但它没有用..
http://www.dotnetfox.com/articles/how-to-highlight-datalist-item-on-mouseover-using-Asp -Net-with-C-Sharp-1040.aspx# [ ^ ]
我怎么解决呢。
请帮帮我..
提前致谢,
Vineetha
Hi,
How to highlight datalist item on mouseover using Asp.Net C#.
I see an article specifying it. but it's not working..
http://www.dotnetfox.com/articles/how-to-highlight-datalist-item-on-mouseover-using-Asp-Net-with-C-Sharp-1040.aspx#[^]
How can I solve it.
Please help me..
Thanks in advance,
Vineetha
推荐答案
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.className='highlight'");
e.Row.Attributes.Add("onmouseout", "this.className='normal'");
}
}
1)创建一个css类并定义我们想要用于在html源页面中突出显示的颜色
ex:For Highlight Grid- highlightGridrow
For Normal Grid- normalGridrow
2)在代码中的RowCreated事件中将onmouseover和onmouseout属性添加到gridview行
protected void dgvTest_RowCreated(object sender,GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add(onmouseover,this.className ='highlightGridrow');
e.Row.Attributes.Add(onmouseout, this.className ='normalGridrow');
}
}
或简单使用
.GridViewCssName:悬停{style Attributes}
。网格:h over {color:#000; text-decoration:none; }
Santhosh
1) Create a css class and define the color we want to use for highlighting in html source of page
ex: For Highlight Grid- highlightGridrow
For Normal Grid- normalGridrow
2)Add onmouseover and onmouseout attributes to gridview rows in RowCreated event in code behind
protected void dgvTest_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.className='highlightGridrow'");
e.Row.Attributes.Add("onmouseout", "this.className='normalGridrow'");
}
}
Or Simply Use
.GridViewCssName:hover{style Attributes}
.Grid:hover { color: #000; text-decoration: none; }
Santhosh
这篇关于如何使用Asp.Net C#在鼠标悬停时突出显示datalist项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文