<script type="text/javascript">
function fOver(obj){
c=obj.style.backgroundColor;
obj.style.backgroundColor="#CAD3E4";
}
function fOut(obj){
obj.style.backgroundColor=c;
}
</script>
<table>
<tr>
<td>用户编号</td>
</tr>
<asp:Repeater ID="rptUser" runat="server">
<ItemTemplate>
<tr style='background-color:<%#(Container.ItemIndex%2==0)?"red":"green"%>' onmouseover="fOver(this);" onmouseout="fOut(this);">
<td><%#Eval("UID")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
Repeater鼠标经过变色
最新推荐文章于 2022-02-25 20:00:37 发布
本文介绍如何在ASP.NET中使用Repeater控件并结合JavaScript来实现表格行背景颜色的动态切换及鼠标悬停效果。通过服务器端代码设置不同行的背景颜色,并利用客户端脚本来改变行的背景色以提升用户体验。
147

被折叠的 条评论
为什么被折叠?



