ShowFlashAd.aspx
<form id="form1" runat="server">
<div>
<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="<%=Pics_Width %>" height="<%=Swf_Height %>">
<param name="allowscriptaccess" value="sameDomain"/>
<param name="movie" value="flash/loader.swf"/>
<param name="quality" value="high"/>/
<param name="bgcolor" value="#F0F0F0"/>
<param name="menu" value="false"/>
<param name="wmode" value="opaque"/>
<param name="flashvars" value="Pics=<%=Pics %>&links=<%=Links %>&texts=<%=Texts %>&borderwidth=<%=Pics_Width %>&borderheight=<%=Pics_Height %>&textheight=<%=Texts_Height %>"/>
</object>
</div>
</form>
这个主要是用在前台显示Flash的,各位一看就知道了,不过要自己去下载一个loader.swf的文件。
ShowFlashAd.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Page_Function_showflashad : System.Web.UI.Page
{
public int Pics_Width = 240;
public int Pics_Height = 180;
public int Texts_Height = 18;
public int Swf_Height;
public string Pics;
public string Links;
public string Texts;
public void Page_Load(object sender, EventArgs e)
{
//链接数据库,并获取数据库中FlashAD表中的数据
SqlConnection objConn = new SqlConnection();
objConn.ConnectionString = ConfigurationManager.ConnectionStrings["yntvuConnectionString"].ConnectionString;
objConn.Open();
SqlCommand objCmd = new SqlCommand();
objCmd.Connection = objConn;
objCmd.CommandText = "Select Top 6 * From FlashAdPic Where IsShow='1' and IsDel='0'";
SqlDataReader objReader=objCmd.ExecuteReader();
//将查询结果保存到数组变量中,并进行调用
string[] imgPics = new string[6];
string[] imgTexts = new string[6];
string[] imgLinks = new string[6];
int i;
for (i = 0; i < 6; i++)
{
objReader.Read();
imgPics[i] = objReader["Pics"].ToString();
imgLinks[i] = objReader["Links"].ToString();
imgTexts[i] = objReader["Texts"].ToString();
Pics = i == 5 ? Pics = Pics + imgPics[i] : Pics + imgPics[i] + "|";
Links = i == 5 ? Links = Links + imgLinks[i]: Links + imgLinks[i] + "|";
Texts = i == 5 ? Texts= Texts + imgTexts[i]: Texts + imgTexts[i] + "|";
}
objConn.Close();
Swf_Height = Pics_Height + Texts_Height;
}
}
======================================================================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class flashControl : System.Web.UI.UserControl
{
public int Pics_Width = 630;
public int Pics_Height = 280;
public int Texts_Height = 20;
public int Swf_Height;
public string Pics;
public string Links;
public string Texts;
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
this.Flashnew();
}
}
public void Flashnew()
{
SqlConnection conn = db.getconn();
SqlDataAdapter sda = new SqlDataAdapter("select top 2 * from News where Ns_PhotoPath<>'' order by Ns_Id desc", conn);
DataSet ds = new DataSet();
sda.Fill(ds, "news");
DataView dv = ds.Tables[0].DefaultView;
if (dv.Table.Rows.Count != 0)
{
for (int i = 0; i < dv.Table.Rows.Count; i++)
{
Pics += dv.Table.Rows[i]["Ns_PhotoPath"].ToString().Trim() + "|";
Links += "news.aspx?id=" + dv.Table.Rows[i]["Ns_Id"].ToString().Trim() + "|";
Texts += dv.Table.Rows[i]["Ns_Subject"].ToString().Trim() + "|";
}
}
sda = new SqlDataAdapter("select top 6 * from Goods where Gs_PhotoPath<>'goodpic/null.jpg' order by Gs_id desc", conn);
ds = new DataSet();
sda.Fill(ds, "news");
dv = ds.Tables[0].DefaultView;
if (dv.Table.Rows.Count != 0)
{
for (int i = 0; i < dv.Table.Rows.Count; i++)
{
Pics += dv.Table.Rows[i]["Gs_PhotoPath"].ToString().Trim() + "|";
Links += "news.aspx?id=" + dv.Table.Rows[i]["Gs_id"].ToString().Trim() + "|";
Texts += dv.Table.Rows[i]["Gs_Name"].ToString().Trim() + "|";
}
Pics = Pics.Substring(0, Pics.LastIndexOf("|")).Trim();//得出图片不含"|";
Links = Links.Substring(0, Links.LastIndexOf("|")).Trim(); //得出路径 不含"|";
Texts = Texts.Substring(0, Texts.LastIndexOf("|")).Trim();
Swf_Height = Pics_Height + Texts_Height;
}
}
}