c#.net 動態讀取 走馬燈代碼執行個體分享

來源:互聯網
上載者:User

前台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();
}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.