|
[学习公共库]asp.net+sql轮换图片效果 |
麦林 发表于 2007/6/21 13:27:42 |
1.flash图片播放器下载址:http://news.ccidnet.com/images/swf/pixviewer.swf
2.源文件pic.ascx添加代码:(红色为flash图片的路径)<script type="text/javascript"> function showPic(pic,link) { var focus_width=553 //显示图片的宽度 var focus_height=180 //显示图片的高度 var swf_height = focus_height var pics=pic; //参数 var links=link; //参数
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="pixviewer.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='+pics+'&links='+links+'&borderwidth='+focus_width+'&borderheight='+focus_height+'">'); document.write('<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&borderwidth='+focus_width+'&borderheight='+focus_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>'); }</script><%=js%>
3.文件pic.ascx.cs代码: public string js; protected void Page_Load(object sender, System.EventArgs e) { if (!this.Page.IsPostBack) { //string str="pic/1.jpg|pic/2.jpg|pic/3.jpg|pic/4.jpg"; //不用数据库时直接写上图片路径 //string strlink ="1.htm|2.htm|3.htm|4.htm"; //图片对应的链接地址 string str = ""; SqlDataReader dr = GetAllAdPic(); //调用类方法 while (dr.Read()) { str += "Pic/" + dr["Url"].ToString() + "|"; // 图片的路径 } string strlink = ""; string imgStr = str.Substring(0, str.Length - 1); js = "<script>showPic(\r'" + imgStr + "',\r'" + strlink + "');</script>"; } } public SqlDataReader GetAllAdPic() //调用存储过程的类写在同一页面了. { Database data = new Database(); SqlDataReader dataReader = null; data.RunProc("GetAllPic", out dataReader); return dataReader; }
4.存储过程GetAllPicCREATE PROCEDURE GetAllPicasselect * from PicGO 表pic字段: picID(int) Url(nvarchar(100))
|
|
|
|

|
.: 公告
|
|
| « | December 2025 | » | | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | | |
|
.: 我的分类(专题)
|
|

.: 最新日志
.: 最新回复
|
|

blog名称:栗色?蓝色? 日志总数:449 评论数量:201 留言数量:37 访问次数:2278992 建立时间:2006年5月16日 |
|

.: 留言板
|

.: 链接
|

|