首页 > 编程 > .NET > 正文

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

2024-07-10 13:16:06
字体:
来源:转载
供稿:网友
[html]

复制代码 代码如下:


<div>
        <table cellpadding="0" cellspacing="0" background="Images/img2/32.jpg">
            <tr>
                <td valign="bottom">
                    <asp:DataList runat="server" RepeatDirection="Horizontal" DataSourceID="ObjectDataSource1">
                        <ItemTemplate>
                            <table>
                                <tr>
                                    <td>
                                        <asp:ImageButton runat="server" ImageUrl='<%#Eval("Spic") %>'
                                            CommandArgument='<%#Eval("ID") %>' />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:LinkButton CommandArgument='<%#Eval("ID") %>' runat="server"
                                            CssClass="bb" Text='<%#Eval("Type") %>'></asp:LinkButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:DataList>
                    <asp:ObjectDataSource runat="server" SelectMethod="SelectInfo"
                        TypeName="HotelDAL.KeFangServices"></asp:ObjectDataSource>
                </td>
                <%-- 这一步很重要 --%>
                <td 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>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表