欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

c#.net 动态读取 走马灯代码实例分享

程序员文章站 2024-03-02 16:04:16
前台html及js脚本: [html] 复制代码 代码如下:
   

前台html及js脚本:

[html]

复制代码 代码如下:

<div>
    <table border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td bgcolor="#cc66ff" 
                style="width: 990px; height: 5px; background-color: #ffffff; text-align: center;">
            </td>
        </tr>
        <tr>
            <td style="border-right: #cccc99 1px solid; border-top: #cccc99 1px solid; border-left: #cccc99 1px solid; width: 990px; border-bottom: #cccc99 1px solid">
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td style="width: 990px; background-color: #ffffff">
                            <div style="width: 990px; height: 139px">
                                <div id="demo" 
                                    style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; overflow: hidden; width: 100%; color: #ffffff; padding-top: 0px">
                                    <table align="left" border="0" cellpadding="0" cellspace="0" cellspacing="0" 
                                        style="width: 900px; height: 139px">
                                        <tr>
                                            <td id="demo1" valign="top">
                                                <table border="0" cellpadding="0" cellspacing="0" width="2000">
                                                    <tr> <asp:label id="label1" runat="server" text="label"></asp:label>
                                                        </tr>

                                                </table>
                                            </td>
                                            <td id="demo2" valign="top">
                                            </td>
                                        </tr>
                                    </table>
                                </div>
<script __designer:dtid="3377854339350821">
var speed3=1//速度数值越大速度越慢
demo2.innerhtml=demo1.innerhtml
function marquee(){
if(demo2.offsetwidth-demo.scrollleft<=0)
demo.scrollleft-=demo1.offsetwidth
else{
demo.scrollleft++
}
}
var mymar=setinterval(marquee,speed3)
demo.onmouseover=function() {clearinterval(mymar)}
demo.onmouseout=function() {mymar=setinterval(marquee,speed3)}
</script>
                                </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td style="width: 100px; height: 5px">
            </td>
        </tr>
    </table>
</div>

 

 cs页的代码:

[csharp]

复制代码 代码如下:

dal_collection dc = new dal_collection();
label1.text = dc.getindexzoumadeng();
 

dal_collection.getindexzoumadeng()的代码:


[csharp]
复制代码 代码如下:

using system.text;

[csharp]

复制代码 代码如下:

public string getindexzoumadeng()
    {

        stringbuilder res = new stringbuilder();
        datatable dt0 = getnewspagedb("select top 10  cn_id, cn_title,cn_intro,cn_url,cn_uid,cn_times from collection order by cn_times desc");
        if (dt0.rows.count == 0)
        {
            res.append("暂无相关数据!");
        }
        else
        {
            for (int i = 0; i < dt0.rows.count; i++)//参见【注释1】
            {
                res.append("<td align=\"center\" height=\"139\" width=\"184\"><img height=\"135\" src=\"" + dt0.rows[i][3].tostring().substring(2) + "\" width=\"180\" /></td>");

            }
            if (dt0.rows.count <= 6)
            {
                res.append(res.tostring());
            }
        }

        return res.tostring();
    }