您的位置:首页 > 移动开发 > Objective-C

使用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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  string null object server div
相关文章推荐