在repeater控件中,如何实现光棒效果

3721_zcx 2014-05-07 04:00:44
想在列表中实现光标效果,但是Repeater控件中并没有Attribute属性,需要请教各位如何修改此代码。

protected void rptRoomInfo_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//光棒效果
if (e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseover", "on=this.style.backgroundColor;this.style.backgroundColor='#99CCFF'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor = on");

}
}
...全文
271 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
happytonice 2014-05-08
  • 打赏
  • 举报
回复
<asp:Repeater ID="Repeater1" runat="server"> <HeaderTemplate> <table> </HeaderTemplate> <ItemTemplate> <tr onmouseover="javascript:this.style.backgroundColor='#f00'" onmouseout="javascript:this.style.backgroundColor='#fff'"> <td><%#Eval("roomNumber") %></td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater>
jimil 2014-05-08
  • 打赏
  • 举报
回复
http://blog.csdn.net/jimil/article/details/25287567 随手写了个。
3721_zcx 2014-05-08
  • 打赏
  • 举报
回复
引用 4 楼 jimil 的回复:
在<ItemTemplate>直接写 onmouseover="javascript:this.style.backgroundColor='Blue';" onmouseout="javascript:this.style.backgroundColor='#FFFFFF';"
谢谢您的回复, 但是是我哪儿写错了的原因吗,我这边一直无法实现。 网上也有好多答案与您的答案类似,但是试过了都无效。

<ItemTemplate>
     <tr onmouseover="javascript:this.style.backgroundColor='#000'"  onmouseout="javascript:this.style.backgroundColor='#fff'">
         <%--onmouseover="this.style.backgroundColor='#000'" onmouseout="this.style.backgroundColor='#fff'"--%>
          <%--<td><asp:Label ID="lblRoomID" runat="server" Text='<%#Eval("roomID") %>'></asp:Label></td>--%>
          <td><asp:Label ID="lblRoomNumber" runat="server" Text='<%#Eval("roomNumber") %>'></asp:Label></td>
           <td><asp:Label ID="lblTypeName" runat="server" Text='<%#Eval("typeName") %>'></asp:Label></td>
           <td><asp:Label ID="lblBedNumber" runat="server" Text='<%#Eval("bedNumber") %>'></asp:Label></td>
           <td><asp:Label ID="lblGuestNumber" runat="server" Text='<%#Eval("guestNumber") %>'></asp:Label></td>
           <td><asp:Label ID="lblDescription" runat="server" Text='<%#Eval("description") %>'></asp:Label></td>
           <td><asp:Label ID="lblState" runat="server" Text='<%#Eval("state") %>'></asp:Label></td>
           <td><a href="EditRoomInfo.aspx?roomID=<%# Eval("roomID") %>&key=1"><img src="Images/edit.gif" /></a> | 
                            <asp:ImageButton ID="imgbtnDelete" CommandName="del" CommandArgument='<%#Eval("roomID") %>' OnClientClick='return confirm("确定要删除吗?")' runat="server" ImageUrl="~/Images/delete.gif" />
      </tr>
</ItemTemplate>
我将我的代码贴出来,麻烦您帮我看看
happytonice 2014-05-08
  • 打赏
  • 举报
回复
类似: <ItemTemplate> <tr onmousemove="overBg()" onmouseout="outBg()"><td>哈哈哈哈</td></tr> </ItemTemplate>
jimil 2014-05-08
  • 打赏
  • 举报
回复
在<ItemTemplate>直接写 onmouseover="javascript:this.style.backgroundColor='Blue';" onmouseout="javascript:this.style.backgroundColor='#FFFFFF';"
  • 打赏
  • 举报
回复
以上代码你复制过去即可
  • 打赏
  • 举报
回复
jquery+CSS 以下是我写的实现的
<script src="Script/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#Table01 tr:odd:not(.TableHeader)").addClass("OddRow");
            $("#Table01 tr:even:not(.TableHeader)").addClass("EvenRow");
            $("#Table01 tr:not(.TableHeader)").hover(function () { c1 = $(this).attr("class"); $(this).addClass("RedRow") }, function () { $(this).removeClass("RedRow"); $(this).addClass(c1) })

        
        })
        
    </script>
    <style type="text/css">
        .style1
        {
            width: 230px;
        }
       .OddRow{ background-color:#FEFDE9}
       .EvenRow{ background-color:#ECFFEC}
       .TableHeader{ background-color:#F9F9F9}
       .RedText{ font-weight:bold; color:Red}
       .GreenText{ color:green}
       .BlueText{ color:Blue}
       .RedRow{ background-color:Gray}
    </style>
3721_zcx 2014-05-08
  • 打赏
  • 举报
回复
[quote=引用 8 楼 happytonice 的回复:] <ItemTemplate> <tr onmouseover="javascript:this.style.backgroundColor='#f00'" onmouseout="javascript:this.style.backgroundColor='#fff'"> <td><%#Eval("roomNumber") %></td> </tr> </ItemTemplate> happytonice, thanks a lot
3721_zcx 2014-05-08
  • 打赏
  • 举报
回复
引用 7 楼 jimil 的回复:
http://blog.csdn.net/jimil/article/details/25287567 随手写了个。
嗯,写得挺简洁明了的,非常感谢!
3721_zcx 2014-05-08
  • 打赏
  • 举报
回复
引用 3 楼 lvxinyi123 的回复:
以上代码你复制过去即可
这次因为主要是为了在Repeater中简单的实现,所以你的这个我暂时无法用上哦。 依旧很感谢您的帮助, 呵呵,还细心的写了那么长,那么详细,非常感谢。
by_封爱 版主 2014-05-08
  • 打赏
  • 举报
回复

               $("#g1 tr").mouseover(function() {
                    $(this).addClass("over");
                }) .mouseout(function() {
                    $(this).removeClass("over");
                })

.over{background-color:#FEFDE9}
直接就用GridView不好吗?? 非得repeter+table才算好?? 然后口口声声说 repeter效率高?
宇哥_ 2014-05-07
  • 打赏
  • 举报
回复
js+jquery。。。
不断更新  Asp.net页面内传参数方法  调用存储过程(两种方法比较)  调用存储过程通用类DBHelper  加密解密  SQL常用DBHelper  Asp.net存储过程无限分类  TreeView无限分类  无限分类MVC  荧光棒效果 获取控件上全选  回车转换成Tab  DataGrid超级连接列  DataGrid行随鼠标变色  数字格式化  日期格式化  打开新的窗口并传送参数  为按钮添加对话框  删除表格选定记录  删除表格记录警告  关于日期格式  表格超连接列传递参数  清空Cookie  获取错误信息并到指定页面  自定义异常处理  javascript小技巧  DotNet 密码加密的技术  用户MD5加密  ASP.net验证码实现  图片水印  防盗链  .NET(C#)连接各类数据库  读取配置文件数据库连接串  正则表达式验证  递归把十进制转换八进制(面试题目)  Mysql测试连接(DLL的引用)(插入与读取)  Asp.Net编辑器Fckeditor的使用  Asp.NetFileUpload上传文件  Asp.NetWebServices的使用  Asp.net手动绑定数据(分页、编辑、删除、加控件等操作)  Asp.netMy97DatePicker4.2日期的使用  Asp.netDataList控件添加删除  Asp.net获取请求的用户信息IP地址  获取世界IP地址库显所在城市信息  MySQL事务处理  SQL内部常用函数  为gridview“删除”列添加确认对话框

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧