点击这里给我发消息 点击这里给我发消息

ASP.NET中利用DataList实现图片无缝滚动

添加时间:2013-12-6
    相关阅读: ASP ASP.NET HTML
<div id="demo" style="overflow: hidden; width: 441px; border: 0px">
        <table width="441" height="130" border="0" cellpadding="0" cellspacing="0" background="Images/img2/32.jpg">
            <tr>
                <td align="center" id="demo1" valign="bottom">
                    <asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" DataSourceID="ObjectDataSource1">
                        <ItemTemplate>
                            <table>
                                <tr>
                                    <td>
                                        <asp:ImageButton ID="imgbtnInfo" runat="server" ImageUrl='<%#Eval("Spic") %>' OnClick="imgbtnInfo_Click"
                                            CommandArgument='<%#Eval("ID") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center">
                                        <asp:LinkButton ID="lkbtnInfo" CommandArgument='<%#Eval("ID") %>' runat="server"
                                            OnClick="lkbtnInfo_Click" CssClass="bb" Text='<%#Eval("Type") %>'></asp:LinkButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:DataList>
                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="SelectInfo"
                        TypeName="HotelDAL.KeFangServices"></asp:ObjectDataSource>
                </td>
                <%-- 这一步很重要 --%>
                <td id="demo2" align="center" valign="bottom">
                </td>
            </tr>
        </table>
    </div>
    <script>
        //滚动的速度,数值越大速度越慢
        var speed = 20
        demo2.innerHTML = demo1.innerHTML
        //从右至左
        function Marquee() {
            if (demo1.offsetWidth - demo.scrollLeft <= 0)
                demo.scrollLeft = 0
            else
                demo.scrollLeft++
        }
        var MyMar = setInterval(Marquee, speed)
        demo.onmouseover = function () { clearInterval(MyMar) }
        demo.onmouseout = function () { MyMar = setInterval(Marquee, speed) }
    </script>
咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册