首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

一个关于Repeater鼠标移动行变色的老有关问题

2013-12-26 
一个关于Repeater鼠标移动行变色的老问题本帖最后由 daijinhua 于 2011-06-25 08:24:36 编辑红色标示的这

一个关于Repeater鼠标移动行变色的老问题
本帖最后由 daijinhua 于 2011-06-25 08:24:36 编辑 红色标示的这句我在其他地方的Repeater中是可以用的,但这里不行.另外我不想用js和后台事件来控制,大家帮我看看
<asp:Repeater ID="Apter" runat="server" OnItemCommand="Apter_ItemCommand">
                                                <HeaderTemplate>
                                                    <tr bgcolor="#BBE2FB" style="font-weight: bold;">
                                                        <td width="5%" background="images/bg.gif">
                                                            <asp:CheckBox ID="cbCheckAll" runat="server" Text="全选" onclick="GetAllCheckBox(this)" />
                                                        </td>
                                                        <td width="5%" align="center" background="images/bg.gif">
                                                            编号
                                                        </td>
                                                        <td align="center" background="images/bg.gif">
                                                            标题
                                                        </td>
                                                        <td width="12%" align="center" background="images/bg.gif">
                                                            添加时间
                                                        </td>
                                                        <td width="7%" align="center" background="images/bg.gif">
                                                            添加人


                                                        </td>
                                                        <td width="20%" align="center" background="images/bg.gif">
                                                            基本操作
                                                        </td>
                                                    </tr>
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                   
 <tr onmouseover="this.style.backgroundColor='#B6D2E0'" onmouseout="this.style.backgroundColor=''">                                                        <td width="5%" bgcolor="#FFFFFF" align="center">
                                                            <asp:CheckBox ID="chkBox" runat="server" />
                                                            <asp:HiddenField ID="hfUid" runat="server" Value='<%#Eval("Id") %>' />
                                                        </td>
                                                        <td height="20" bgcolor="#FFFFFF" align="center">
                                                            <%# Container.ItemIndex+1 %>
                                                        </td>
                                                        <td height="20" bgcolor="#FFFFFF">


                                                            <a href="AnnounceShow.aspx?id=<%#Eval("Id") %>" title='<%#Eval("Title") %>'>
                                                                <%#CCH.Common.ValidationHelper.StringTrunCate(Eval("Title").ToString(),38,"...")%></a>
                                                        </td>
                                                        <td height="20" bgcolor="#FFFFFF" align="center">
                                                            <%#Eval("Addtime") %>
                                                        </td>
                                                        <td height="20" bgcolor="#FFFFFF" align="center">
                                                            <%#Eval("AddPepole")%>
                                                        </td>
                                                        <td height="20" bgcolor="#FFFFFF" align="center">
                                                            <asp:Image ID="Img_Add" runat="server" ImageUrl="images/edt.gif" CssClass="img_ud" />
                                                            <asp:LinkButton ID="AddBtn" runat="server" CommandArgument='<%#Eval("ID") %>' CommandName="Eit">编辑</asp:LinkButton>&nbsp;
                                                            <asp:Image ID="Img_Del" runat="server" ImageUrl="images/del.gif" CssClass="img_ud" />
                                                            <asp:LinkButton ID="DelBtn" runat="server" CommandName="Del" CommandArgument='<%#Eval("ID") %>'
                                                                OnClientClick="return confirm('确认要删除吗?')">删除</asp:LinkButton>


                                                        </td>
                                                    </tr>
                                                </ItemTemplate>
                                            </asp:Repeater>
[解决办法]
代码没什么问题,楼主可以看看生成HTML页面后的源代码。。。
[解决办法]
看一下这个

<script type="text/javascript">
function mOver(obj){
c=obj.style.backgroundColor;
obj.style.backgroundColor="#ffffff";
}
function mOut(obj){
obj.style.backgroundColor=c;
}
</script>

<ItemTemplate>
          <tr style='background:<%#(Container.ItemIndex%2==0)?"#e1e1e1":"#D2EDFD"%>' onmouseover="mOver(this)" onmouseout="mOut(this)" >
          <td><span><%#Container.ItemIndex+1%></span></td>
          <td><asp:TextBox ID="TxtNewMenuName" runat="server" Text='<%#Eval("Menuname") %>'></asp:TextBox></td>
           <td><asp:LinkButton ID="LbtnShowOrHiden" CommandName="ShowOrHiden" CommandArgument='<%#Eval("ID") %>' runat="server" Text='<%#Eval("IsDisplay").ToString()=="1" ? "隐藏":"显示" %>' ></asp:LinkButton>
           </td>
    
           <td><asp:ImageButton ID="IbtnDown" ImageUrl="~/Admin/images/down.gif" CommandName="Down" CommandArgument='<%#Eval("ID") %>'  runat="server" />
           <asp:ImageButton ID="IbtnUp" CommandName="Up" CommandArgument='<%#Eval("ID") %>' ImageUrl="~/Admin/images/up.gif" runat="server" /></td>
           <td><asp:LinkButton ID="LbtnEdit" CommandName="Edit" Text="修改" CommandArgument='<%#Eval("ID") %>' runat="server" ></asp:LinkButton>
            <asp:LinkButton ID="LbtDel" CommandName="Del" OnClientClick="return confirm('确定要删除么?')" CommandArgument='<%#Eval("ID") %>'  Text="删除" runat="server"></asp:LinkButton>
            </td>
          </tr>
         </ItemTemplate> 
[解决办法]
输出以后 把 源代码 复制到 一个 html里面 然后调试下。
[解决办法]
//光棒效果代码

protected void gvMemberList_RowDataBound(object secder, GridViewRowEventArgs e) 
{    
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        e.Row.Attributes.Add("onMouseOver", "t=this.style.backgroundColor;this.style.backgroundColor='#ebebce'");
        e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=t");
        e.Row.Attributes.Add("onclick", "if(this.style.backgroundColor=='#ebebce')this.style.backgroundColor=t;else{this.style.backgroundColor='#ebebce'}");
        e.Row.Attributes.CssStyle.Add("cursor", "hand");


    }
}
[解决办法]
背景色掩盖了其他色,好好的改,加油
[解决办法]
恩  该是正道
[解决办法]
td height="20" bgcolor="#FFFFFF" align="center">

把所有td里的颜色去掉,因为td比tr的优先级要高
[解决办法]

引用:
改了好多个颜色都不行 难道背景色和变色只能选一个?不能选深的颜色把背景色给显示吗?


你的onmouseover要去遍历this.elements,把它们的背景色保存成自定义属性,然后再将背景色设置为B6D2E0;而onmouseout则是要遍历this.elements,然后把保存的背景色恢复设置。

热点排行