如Flash效果的滚动图片
Default.aspx 頁面
protected void FlashLoad()
{
conn.Open();
try
{
string sqlflash = "select top 5 * from [ent_news] where ent_img<>'' order by newsid desc";
SqlCommand cmd = new SqlCommand(sqlflash, conn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Pic += dr["ent_img"].ToString() + "|";
linkstr += "../foredsp/Celeb_three/celeb_three1page.aspx?id=" + dr["newsid"].ToString() + "|";
textstr += dr["title"].ToString() + "|";
}
dr.Close();
this.picture.Value = Pic.ToString().Trim();
this.picturelink.Value = linkstr.ToString().Trim();
this.txtstr.Value = textstr.ToString().Trim();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
finally
{
conn.Close();
}
}
Default.aspx.cs 頁面
<input id="picture" type="hidden" style="width: 0px" runat="server" />
<input id="picturelink" style="width: 0px" type="hidden" runat="server" />
<input id="txtstr" style="width: 0px" type="hidden" runat="server" />
<script type="text/javascript">
var focus_width=350
var focus_height=212
var text_height=25
var swf_height = focus_height+text_height
if(document.getElementById("picture") != null || document.getElementById("picture").value !="")
{
var pic= document.getElementById("picture").value;
}
else
{
var pic="";
}
if(document.getElementById("picturelink") != null || document.getElementById("picturelink").value !="")
{
var plink= document.getElementById("picturelink").value;
}
else
{
var plink="";
}
if(document.getElementById("txtstr") != null || document.getElementById("txtstr").value !="")
{
var texts= document.getElementById("txtstr").value;
}
else
{
var texts="";
}
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="../manager/upload/flash/focus.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics='+pic+'&links='+plink+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
document.write('<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pic+'&links='+plink+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>');
</script>