使用ItemCreated事件和onmouseover两种方式 实现Repeater鼠标滑动效果
2012-07-09 14:11
615 查看
第一种:使用ItemCreated事件实现 protected void repcpw_OperLog_ItemCreated(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
if (e.Item.FindControl("itl") != null)
{
HtmlTableRow htr_itl = (HtmlTableRow)e.Item.FindControl("itl");
ApplyStyle(htr_itl, "#fff");
}
}
if (e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.Item.FindControl("att") != null)
{
HtmlTableRow htr_att = (HtmlTableRow)e.Item.FindControl("att");
ApplyStyle(htr_att, "#E9F2FB");
}
}
}
private void ApplyStyle(HtmlTableRow htr, string trBackColor)
{
string onmouseoverStyle = "this.style.backgroundColor='#BCE774'";
string onmouseoutStyle = "this.style.backgroundColor='@BackColor'";
htr.Attributes.Add("onmouseover", onmouseoverStyle);
htr.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", trBackColor));
}
2.使用onmouseover/onmouseout
<div style=" line-height:20px;border-bottom: #fff 1px solid; background-color:#E9F2FB" id="att" runat="server" onmouseover="tempBgColor=this.style.backgroundColor;this.style.backgroundColor='#BCE774';" onmouseout="this.style.backgroundColor=tempBgColor"
>
</div>
{
if (e.Item.ItemType == ListItemType.Item)
{
if (e.Item.FindControl("itl") != null)
{
HtmlTableRow htr_itl = (HtmlTableRow)e.Item.FindControl("itl");
ApplyStyle(htr_itl, "#fff");
}
}
if (e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.Item.FindControl("att") != null)
{
HtmlTableRow htr_att = (HtmlTableRow)e.Item.FindControl("att");
ApplyStyle(htr_att, "#E9F2FB");
}
}
}
private void ApplyStyle(HtmlTableRow htr, string trBackColor)
{
string onmouseoverStyle = "this.style.backgroundColor='#BCE774'";
string onmouseoutStyle = "this.style.backgroundColor='@BackColor'";
htr.Attributes.Add("onmouseover", onmouseoverStyle);
htr.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", trBackColor));
}
2.使用onmouseover/onmouseout
<div style=" line-height:20px;border-bottom: #fff 1px solid; background-color:#E9F2FB" id="att" runat="server" onmouseover="tempBgColor=this.style.backgroundColor;this.style.backgroundColor='#BCE774';" onmouseout="this.style.backgroundColor=tempBgColor"
>
</div>
相关文章推荐
- 使用ES6实现一个绚丽的鼠标滑动效果
- 鼠标滚轮事件兼容处理、实现内容横向滑动效果
- Repeater中实现“鼠标滑动行变色”的效果
- jQuery图片无缝滑动效果的两种实现方式
- MyBatis之自查询使用递归实现 N级联动效果(两种实现方式)
- 自定义View想使用Scroller实现滑动效果,但是事件接收出现问题,只收到ACTION_DOWN,而无法收到ACTION_MOVE, ACTION_UP等消息的处理
- 两种方法使用jquery实现左右移动效果(包含each遍历方式)
- 史上最全的CSS hack方式一览 jQuery 图片轮播的代码分离 JQuery中的动画 C#中Trim()、TrimStart()、TrimEnd()的用法 marquee 标签的使用详情 js鼠标事件 js添加遮罩层 页面上通过地址栏传值时出现乱码的两种解决方法 ref和out的区别在c#中 总结
- 使用PopupWindow和Activity两种不同的方式实现弹窗效果
- MyBatis之自查询使用递归实现 N级联动效果(两种实现方式)
- 使用PopupWindow和Activity两种不同的方式实现弹窗效果
- 使用OpenLayers实现一个在鼠标点击处添加标记的效果
- ExpandableListView实例(二)_两种方式实现QQ中组后面显示子条目数量效果
- Android 使用Scroller实现绚丽的ListView左右滑动删除Item效果
- 实现瀑布流布局效果两种方式
- javascript实现百度地图鼠标滑动事件显示、隐藏
- 使用ViewFlipper实现图片左右滑动效果
- Java使用SFTP和FTP两种连接方式实现对服务器的上传下载
- Cocos2dx实现翻牌效果(CCScaleTo与CCOrbitCamera两种方式)
- Android 使用NineOldAndroids实现绚丽的ListView左右滑动删除Item效果