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

asp.net c#动态读取 走马灯代码

程序员文章站 2023-09-09 22:33:41
前台html及js脚本:   [html] 

     

前台html及js脚本:

 

[html] 
<p> 
    <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"> 
                            <p style="width: 990px; height: 139px"> 
                                <p 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> <:label id="label1" runat="server" text="label"></asp:label> 
                                                        </tr> 
                                                    
                                                </table> 
                                            </td> 
                                            <td id="demo2" valign="top"> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </p> 
<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.onmouver=function() {clearinterval(mymar)} 
demo.onmouseout=function() {mymar=setinterval(marquee,speed3)} 
</script> 
                                </p> 
                        </td> 
                    </tr> 
                </table> 
            </td> 
        </tr> 
        <tr> 
            <td style="width: 100px; height: 5px"> 
            </td> 
        </tr> 
    </table> 
</p> 

 

 cs页的代码:

[csharp] 
dal_collection dc = new dal_collection(); 
label1.text = dc.getindexzoumadeng(); 
 

dal_collection.getindexzoumadeng()的代码:

[csharp] 
<p>using system.text;</p> 
[csharp] view plaincopy
  
[csharp] view plaincopy
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(); 
    }