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

[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++
        }  www.jb51.net
        var MyMar = setInterval(Marquee, speed)
        demo.onmouseover = function () { clearInterval(MyMar) }
        demo.onmouseout = function () { MyMar = setInterval(Marquee, speed) } 
    </script>

您可能感兴趣的文章:

  • asp.net中Datalist使用数字分页的实现方法
  • asp.net中将数据库绑定到DataList控件的实现方法与实例代码
  • ASP.Net 之Datalist删除功能详解附代码
  • asp.net datalist绑定数据后可以上移下移实现示例
  • 在ASP.NET 2.0中操作数据之三十五:使用Repeater和DataList单页面实现主/从报表
  • 在ASP.NET 2.0中操作数据之三十六:在DataList里编辑和删除数据概述
  • 在ASP.NET 2.0中操作数据之三十七:DataList批量更新
  • asp.net控件DataList分页用法
  • 在ASP.NET 2.0中操作数据之三十九:在DataList的编辑界面里添加验证控件
  • 在ASP.NET 2.0中操作数据之四十:自定义DataList编辑界面