onmouseover和onmouseout在Repeater控件中应用
2011-06-25 10:41
323 查看
如果你曾看过这篇,http://www.cnblogs.com/insus/articles/1411057.html ,它是在GridView控件中演示,但是它的方法在Repeater控件是无法复制的。
由于看到论坛上有网友问及,花上一点点时间做了Repeater控件的演示。首先看看效果(动画结束,尝试刷新网页):
View Code
protected void Repeater1_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, htr_itl.BgColor);
}
}
if (e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.Item.FindControl("att") != null)
{
HtmlTableRow htr_att = (HtmlTableRow)e.Item.FindControl("att");
ApplyStyle(htr_att, htr_att.BgColor);
}
}
}
private void ApplyStyle(HtmlTableRow htr, string trBackColor)
{
string onmouseoverStyle = "this.style.backgroundColor='Peachpuff'";
string onmouseoutStyle = "this.style.backgroundColor='@BackColor'";
htr.Attributes.Add("onmouseover", onmouseoverStyle);
htr.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", trBackColor));
}
由于看到论坛上有网友问及,花上一点点时间做了Repeater控件的演示。首先看看效果(动画结束,尝试刷新网页):
View Code
protected void Repeater1_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, htr_itl.BgColor);
}
}
if (e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.Item.FindControl("att") != null)
{
HtmlTableRow htr_att = (HtmlTableRow)e.Item.FindControl("att");
ApplyStyle(htr_att, htr_att.BgColor);
}
}
}
private void ApplyStyle(HtmlTableRow htr, string trBackColor)
{
string onmouseoverStyle = "this.style.backgroundColor='Peachpuff'";
string onmouseoutStyle = "this.style.backgroundColor='@BackColor'";
htr.Attributes.Add("onmouseover", onmouseoverStyle);
htr.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", trBackColor));
}
相关文章推荐
- Repeater控件添加onmouseover和onmouseout事件
- Repeater控件的应用
- asp:Repeater控件的应用,System.Data.DataRowView
- 实现onmouseover和onmouseout应用于RadioButtonList或CheckBoxList控件上
- 前台应用----------嵌套repeater控件
- onmouseover和onmouseout在GridView中应用 Ver2
- 【总结】——Repeater控件详细应用
- Repeater控件的应用
- Webfrom 生成流水号 组合查询 Repeater中单选与复选控件的使用 JS实战应用
- 在ImageButton上应用onmouseover和onmouseout事件
- onmouseover和onmouseout在GridView中应用
- GridView,DataList,Repeater控件应用技巧
- 关于asp.net中Repeater控件的一些应用
- GridView,DataList,Repeater控件应用技巧
- 实现onmouseover和onmouseout应用于RadioButtonList或CheckBoxList控件上
- 分类页面:repeater控件的应用
- Repeater控件应用示例
- repeater控件的应用
- Webfrom 生成流水号 组合查询 Repeater中单选与复选控件的使用 JS实战应用
- 在ImageButton上应用onmouseover和onmouseout事件