网页左右浮动广告,包括ASP.NET后台管理

aspx

-----------

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FloatADS.aspx.cs" Inherits="AD_admin_FloatADS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>首页左右浮动广告管理</title>

<link href="../../PigeonMIS/CSS/manage_style3.css" type="text/css" rel="Stylesheet" />

</head>

<body>

<form ></asp:RegularExpressionValidator></td>

</tr>

</table>

</td>

</tr>

</table>

</div>

</form>

</body>

</html>

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.Xml;

using System.IO;

using System.Text;

public partial class AD_admin_FloatADS : System.Web.UI.Page

{

#region 静态变量

public static string adLeftType;

public static string adLeftHref;

public static string adLeftWidth;

public static string adLeftHeight;

public static string adLeftSrc;

public static string adRightType;

public static string adRightHref;

public static string adRightWidth;

public static string adRightHeight;

public static string adRightSrc;

public static string marginTop;

public static string marginLeft;

private static XmlDocument xmlDoc;

#endregion

protected void Page_Load(object sender, EventArgs e)

{

if(!Page.IsPostBack)

{

LoadXml();

ReadXML();

Bind();

}

}

private void LoadXml()

{

xmlDoc = new XmlDocument();

xmlDoc.Load(Server.MapPath("~/CSS/AD.XML"));

}

private void ReadXML()

{

XmlNode xmldocSelect = xmlDoc.SelectSingleNode("/Root/Content");

XmlNodeList nodeList = xmldocSelect.ChildNodes;

foreach (XmlNode node in nodeList)

{

XmlElement xm = (XmlElement)node;

switch(xm.Name)

{

case "adLeftHeight":

adLeftHeight = xm.InnerText;

break;

case "adLeftHref":

adLeftHref = xm.InnerText;

break;

case "adLeftSrc":

adLeftSrc = xm.InnerText;

break;

case "adLeftType":

adLeftType = xm.InnerText;

break;

case "adLeftWidth":

adLeftWidth = xm.InnerText;

break;

case "adRightHeight":

adRightHeight = xm.InnerText;

break;

case "adRightHref":

adRightHref = xm.InnerText;

break;

case "adRightSrc":

adRightSrc = xm.InnerText;

break;

case "adRightType":

adRightType = xm.InnerText;

break;

case "adRightWidth":

adRightWidth = xm.InnerText;

break;

case "marginTop":

marginTop = xm.InnerText;

break;

case "marginLeft":

marginLeft = xm.InnerText;

break;

}

}

}

private void Bind()

{

//左边广告

if (adLeftType == "jpg")

{

RadioButton1.Checked = true;

}

else

{

RadioButton2.Checked = true;

}

if (adLeftSrc == "")

{

txtadLeftSrc.Text = "./images/ad1.jpg";

}

else {

txtadLeftSrc.Text = adLeftSrc;

}

if (adLeftWidth == "" || adLeftWidth == null)

{

txtLeftWidth.Text="";

}

else

{

txtLeftWidth.Text=adLeftWidth;

}

if (adLeftHeight == "" || adLeftHeight == null)

{

txtLeftHeight.Text = "";

}

else

{

txtLeftHeight.Text = adLeftHeight;

}

txtLeftURL.Text = adLeftHref;

//右边广告

if (adRightType == "jpg")

{

RadioButton3.Checked = true;

}

else

{

RadioButton4.Checked = true;

}

if (adRightSrc == "")

{

txtadRightSrc.Text = "./images/ad1.jpg";

}

else

{

txtadRightSrc.Text = adRightSrc;

}

if (adRightWidth == "" || adRightWidth == null)

{

txtRightWidth.Text = "";

}

else

{

txtRightWidth.Text = adRightWidth;

}

if (adRightHeight == "" || adRightHeight == null)

{

txtRightHeight.Text = "";

}

else

{

txtRightHeight.Text = adRightHeight;

}

txtRightURL.Text = adRightHref;

//公共属性

txtTopMargin.Text = marginTop;

txtLefyMargin.Text = marginLeft;

}

public void CreateJS(string filePath)

{

string path = System.Web.HttpContext.Current.Server.MapPath(filePath);

Encoding code = Encoding.GetEncoding("gb2312");

System.IO.FileInfo fileinfo = new FileInfo(path);

//判断文件否存在,不存在则创建

if (!fileinfo.Exists)

{

StreamWriter sw=new StreamWriter(fileinfo.Create(),code);

sw.WriteLine("var adLeftSrc = \""+adLeftSrc+"\";");

sw.WriteLine("var adLeftFlash = \"" + adLeftType + "\";");

sw.WriteLine("var adLeftHref = \"" + adLeftHref + "\";");

sw.WriteLine("var adLeftWidth = " + adLeftWidth + ";");

sw.WriteLine("var adLeftHeight = " + adLeftHeight + "");

sw.WriteLine("var adRightSrc = \"" + adRightSrc + "\";");

sw.WriteLine("var adRightFlash = \"" + adRightType + "\";");

sw.WriteLine("var adRightHref = \"" + adRightHref + "\";");

sw.WriteLine("var adRightWidth = " + adRightWidth + ";");

sw.WriteLine("var adRightHeight = " + adRightHeight + "");

sw.WriteLine("var marginTop = " + marginTop + ";");

sw.WriteLine("var marginLeft = " + marginLeft + "");

sw.WriteLine("var navUserAgent = navigator.userAgent;");

sw.WriteLine("var closeAD=false;");

sw.WriteLine("function load(){judge();move();}");

sw.WriteLine("function move() {judge();setTimeout(\"move();\",80)}");

sw.WriteLine("function judge(){");

sw.WriteLine("if (closeAD){");

sw.WriteLine("document.getElementById(\"adRightFloat\").style.display = \"none\";");

sw.WriteLine("document.getElementById(\"adLeftFloat\").style.display = \"none\";");

sw.WriteLine("return;");

sw.WriteLine("}");

sw.WriteLine(" if (navUserAgent.indexOf(\"Firefox\") >= 0 || navUserAgent.indexOf(\"Opera\") >= 0) {");

sw.WriteLine("if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - adLeftHeight - marginTop + 'px';}");

sw.WriteLine("if (adRightSrc != \"\") {");

sw.WriteLine("document.getElementById(\"adRightFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - adRightHeight - marginTop + 'px';");

sw.WriteLine("document.getElementById(\"adRightFloat\").style.left = ((document.body.clientWidth > document.documentElement.clientWidth)?document.body.clientWidth:document.documentElement.clientWidth) - adRightWidth - marginLeft + 'px';");

sw.WriteLine("}");

sw.WriteLine("}");

sw.WriteLine("else{");

sw.WriteLine("if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - adLeftHeight - marginTop + 'px';}");

sw.WriteLine("if (adRightSrc != \"\") {");

sw.WriteLine("document.getElementById(\"adRightFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - adRightHeight - marginTop + 'px';");

sw.WriteLine("document.getElementById(\"adRightFloat\").style.left = ((document.documentElement.clientWidth == 0)?document.body.clientWidth:document.documentElement.clientWidth) - adRightWidth - marginLeft + 'px';");

sw.WriteLine("}");

sw.WriteLine("}");

sw.WriteLine("if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.left = marginLeft + 'px';}");

sw.WriteLine("}");

sw.WriteLine("if (adLeftSrc != \"\") {");

sw.WriteLine("if (adLeftFlash == \"flash\") {");

sw.WriteLine("document.write(\"<div adLeftFloat\\\" position: absolute;width:\\\" + adLeftWidth + \\\";\\\"><a href=\\\"\" + adLeftHref +\"\\\"><embed src=\\\"\" + adLeftSrc + \"\\\" quality=\\\"high\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\" type=\\\"application/x-shockwave-flash\\\"></embed></a><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"></div>\");");

sw.WriteLine("}");

sw.WriteLine("else{");

sw.WriteLine("document.write(\"<div adLeftFloat\\\" position: absolute;width:\" + adLeftWidth + \";\\\"><a href=\\\"\" + adLeftHref +\"\\\"><img src=\\\"\" + adLeftSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\" 0\\\" \\></a><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"></div>\");");

sw.WriteLine("}");

sw.WriteLine("}");

sw.WriteLine("if (adRightSrc != \"\") {");

sw.WriteLine("if (adRightFlash == \"flash\") {");

sw.WriteLine("document.write(\"<div adRightFloat\\\" position: absolute;width:\" + adRightWidth + \";\\\"><a href=\\\"\" + adRightHref +\"\\\"><embed src=\\\"\" + adRightSrc +\"\\\" quality=\\\"high\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\" type=\\\"application/x-shockwave-flash\\\"></a></embed><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"></div>\");");

sw.WriteLine("}");

sw.WriteLine("else{");

sw.WriteLine("document.write(\"<div adRightFloat\\\" position: absolute;width:\" + adRightWidth + \";\\\"><a href=\\\"\" + adRightHref +\"\\\"><img src=\\\"\" + adRightSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\" 0\\\" \\></a><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"/></div>\");");

sw.WriteLine("}");

sw.WriteLine("}");

sw.WriteLine("load();");

sw.Flush();

sw.Close();

}

else

{

fileinfo.Delete();

StreamWriter sw = new StreamWriter(fileinfo.Create(), code);

sw.WriteLine("var adLeftSrc = \"" + adLeftSrc + "\";");

sw.WriteLine("var adLeftFlash = \"" + adLeftType + "\";");

sw.WriteLine("var adLeftHref = \"" + adLeftHref + "\";");

sw.WriteLine("var adLeftWidth = " + adLeftWidth + ";");

sw.WriteLine("var adLeftHeight = " + adLeftHeight + ";");

sw.WriteLine("var adRightSrc = \"" + adRightSrc + "\";");

sw.WriteLine("var adRightFlash = \"" + adRightType + "\";");

sw.WriteLine("var adRightHref = \"" + adRightHref + "\";");

sw.WriteLine("var adRightWidth = " + adRightWidth + ";");

sw.WriteLine("var adRightHeight = " + adRightHeight + ";");

sw.WriteLine("var marginTop = " + marginTop + ";");

sw.WriteLine("var marginLeft = " + marginLeft + ";");

sw.WriteLine("var navUserAgent = navigator.userAgent;");

sw.WriteLine("var closeAD=false;");

sw.WriteLine("function load(){judge();move();}");

sw.WriteLine("function move() {judge();setTimeout(\"move();\",80)}");

sw.WriteLine("function judge(){");

sw.WriteLine("if (closeAD){");

sw.WriteLine("document.getElementById(\"adRightFloat\").style.display = \"none\";");

sw.WriteLine("document.getElementById(\"adLeftFloat\").style.display = \"none\";");

sw.WriteLine("return;");

sw.WriteLine("}");

sw.WriteLine(" if (navUserAgent.indexOf(\"Firefox\") >= 0 || navUserAgent.indexOf(\"Opera\") >= 0) {");

sw.WriteLine("if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - adLeftHeight - marginTop + 'px';}");

sw.WriteLine("if (adRightSrc != \"\") {");

sw.WriteLine("document.getElementById(\"adRightFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - adRightHeight - marginTop + 'px';");

sw.WriteLine("document.getElementById(\"adRightFloat\").style.left = ((document.body.clientWidth > document.documentElement.clientWidth)?document.body.clientWidth:document.documentElement.clientWidth) - adRightWidth - marginLeft + 'px';");

sw.WriteLine("}");

sw.WriteLine("}");

sw.WriteLine("else{");

sw.WriteLine("if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - adLeftHeight - marginTop + 'px';}");

sw.WriteLine("if (adRightSrc != \"\") {");

sw.WriteLine("document.getElementById(\"adRightFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - adRightHeight - marginTop + 'px';");

sw.WriteLine("document.getElementById(\"adRightFloat\").style.left = ((document.documentElement.clientWidth == 0)?document.body.clientWidth:document.documentElement.clientWidth) - adRightWidth - marginLeft + 'px';");

sw.WriteLine("}");

sw.WriteLine("}");

sw.WriteLine("if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.left = marginLeft + 'px';}");

sw.WriteLine("}");

sw.WriteLine("if (adLeftSrc != \"\") {");

sw.WriteLine("if (adLeftFlash == \"flash\") {");

sw.WriteLine("document.write(\"<div adLeftFloat\\\" position: absolute;width:\\\" + adLeftWidth + \\\";\\\"><a href=\\\"\" + adLeftHref +\"\\\"><embed src=\\\"\" + adLeftSrc + \"\\\" quality=\\\"high\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\" type=\\\"application/x-shockwave-flash\\\"></embed></a><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"></div>\");");

sw.WriteLine("}");

sw.WriteLine("else{");

sw.WriteLine("document.write(\"<div adLeftFloat\\\" position: absolute;width:\" + adLeftWidth + \";\\\"><a href=\\\"\" + adLeftHref +\"\\\"><img src=\\\"\" + adLeftSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\" 0\\\" \\></a><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"></div>\");");

sw.WriteLine("}");

sw.WriteLine("}");

sw.WriteLine("if (adRightSrc != \"\") {");

sw.WriteLine("if (adRightFlash == \"flash\") {");

sw.WriteLine("document.write(\"<div adRightFloat\\\" position: absolute;width:\" + adRightWidth + \";\\\"><a href=\\\"\" + adRightHref +\"\\\"><embed src=\\\"\" + adRightSrc +\"\\\" quality=\\\"high\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\" type=\\\"application/x-shockwave-flash\\\"></a></embed><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"></div>\");");

sw.WriteLine("}");

sw.WriteLine("else{");

sw.WriteLine("document.write(\"<div adRightFloat\\\" position: absolute;width:\" + adRightWidth + \";\\\"><a href=\\\"\" + adRightHref +\"\\\"><img src=\\\"\" + adRightSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\" 0\\\" \\></a><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"/></div>\");");

sw.WriteLine("}");

sw.WriteLine("}");

sw.WriteLine("load();");

sw.Flush();

sw.Close();

//StreamWriter sw = new StreamWriter(fileinfo.Open(FileMode.Open), code);

//sw.WriteLine("var adLeftSrc = \"" + adLeftSrc + "\";");

//sw.WriteLine("var adLeftFlash = \"" + adLeftType + "\";");

//sw.WriteLine("var adLeftHref = \"" + adLeftHref + "\";");

//sw.WriteLine("var adLeftWidth = " + adLeftWidth + ";");

//sw.WriteLine("var adLeftHeight = " + adLeftHeight + "");

//sw.WriteLine("var adRightSrc = \"" + adRightSrc + "\";");

//sw.WriteLine("var adRightFlash = \"" + adRightType + "\";");

//sw.WriteLine("var adRightHref = \"" + adRightHref + "\";");

//sw.WriteLine("var adRightWidth = " + adRightWidth + ";");

//sw.WriteLine("var adRightHeight = " + adRightHeight + "");

//sw.WriteLine("var marginTop = " + marginTop + ";");

//sw.WriteLine("var marginLeft = " + marginLeft + ";");

//sw.WriteLine("var navUserAgent = navigator.userAgent;");

//sw.WriteLine("var closeAD=false;");

//sw.WriteLine("function load(){judge();move();}");

//sw.WriteLine("function move() {judge();setTimeout(\"move();\",80)}");

//sw.WriteLine("function judge(){");

//sw.WriteLine("if (closeAD){");

//sw.WriteLine("document.getElementById(\"adRightFloat\").style.display = \"none\";");

//sw.WriteLine("document.getElementById(\"adLeftFloat\").style.display = \"none\";");

//sw.WriteLine("return;");

//sw.WriteLine("}");

//sw.WriteLine(" if (navUserAgent.indexOf(\"Firefox\") >= 0 || navUserAgent.indexOf(\"Opera\") >= 0) {");

//sw.WriteLine("if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - adLeftHeight - marginTop + 'px';}");

//sw.WriteLine("if (adRightSrc != \"\") {");

//sw.WriteLine("document.getElementById(\"adRightFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - adRightHeight - marginTop + 'px';");

//sw.WriteLine("document.getElementById(\"adRightFloat\").style.left = ((document.body.clientWidth > document.documentElement.clientWidth)?document.body.clientWidth:document.documentElement.clientWidth) - adRightWidth - marginLeft + 'px';");

//sw.WriteLine("}");

//sw.WriteLine("}");

//sw.WriteLine("else{");

//sw.WriteLine("if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - adLeftHeight - marginTop + 'px';}");

//sw.WriteLine("if (adRightSrc != \"\") {");

//sw.WriteLine("document.getElementById(\"adRightFloat\").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - adRightHeight - marginTop + 'px';");

//sw.WriteLine("document.getElementById(\"adRightFloat\").style.left = ((document.documentElement.clientWidth == 0)?document.body.clientWidth:document.documentElement.clientWidth) - adRightWidth - marginLeft + 'px';");

//sw.WriteLine("}");

//sw.WriteLine("}");

//sw.WriteLine("if (adLeftSrc != \"\") {document.getElementById(\"adLeftFloat\").style.left = marginLeft + 'px';}");

//sw.WriteLine("}");

//sw.WriteLine("if (adLeftSrc != \"\") {");

//sw.WriteLine("if (adLeftFlash == \"flash\") {");

//sw.WriteLine("document.write(\"<div adLeftFloat\\\" position: absolute;width:\\\" + adLeftWidth + \\\";\\\"><a href=\\\"\" + adLeftHref +\"\\\"><embed src=\\\"\" + adLeftSrc + \"\\\" quality=\\\"high\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\" type=\\\"application/x-shockwave-flash\\\"></embed></a><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"></div>\");");

//sw.WriteLine("}");

//sw.WriteLine("else{");

//sw.WriteLine("document.write(\"<div adLeftFloat\\\" position: absolute;width:\" + adLeftWidth + \";\\\"><a href=\\\"\" + adLeftHref +\"\\\"><img src=\\\"\" + adLeftSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\" 0\\\" \\></a><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"></div>\");");

//sw.WriteLine("}");

//sw.WriteLine("}");

//sw.WriteLine("if (adRightSrc != \"\") {");

//sw.WriteLine("if (adRightFlash == \"flash\") {");

//sw.WriteLine("document.write(\"<div adRightFloat\\\" position: absolute;width:\" + adRightWidth + \";\\\"><a href=\\\"\" + adRightHref +\"\\\"><embed src=\\\"\" + adRightSrc +\"\\\" quality=\\\"high\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\" type=\\\"application/x-shockwave-flash\\\"></a></embed><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"></div>\");");

//sw.WriteLine("}");

//sw.WriteLine("else{");

//sw.WriteLine("document.write(\"<div adRightFloat\\\" position: absolute;width:\" + adRightWidth + \";\\\"><a href=\\\"\" + adRightHref +\"\\\"><img src=\\\"\" + adRightSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\" 0\\\" \\></a><br><br><img src=\\\"images/close.gif\\\" onclick=\\\"closeBanner();\\\"/></div>\");");

//sw.WriteLine("}");

//sw.WriteLine("}");

//sw.WriteLine("load();");

//sw.Flush();

//sw.Close();

}

}

protected void btnCreateJS_Click(object sender, EventArgs e)

{

CreateJS("~/CSS/ad6.js");

}

protected void btnAdd_Click(object sender, EventArgs e)

{

if (txtadLeftSrc.Text.Substring(txtadLeftSrc.Text.LastIndexOf('.') + 1).ToLower() == "swf")

{

if (RadioButton1.Checked == true)

{

RadioButton2.Checked = true;

RadioButton1.Checked = false;

}

}

else

{

if (RadioButton1.Checked == false)

{

RadioButton2.Checked = false;

RadioButton1.Checked = true;

}

}

if (txtadRightSrc.Text.Substring(txtadRightSrc.Text.LastIndexOf('.') + 1).ToLower() == "swf")

{

if (RadioButton3.Checked == true)

{

RadioButton4.Checked = true;

RadioButton3.Checked = false;

}

}

else {

if(RadioButton3.Checked==false)

{

RadioButton4.Checked = false;

RadioButton3.Checked = true;

}

}

XmlNode xmldocSelect = xmlDoc.SelectSingleNode("/Root/Content");

XmlNodeList nodeList = xmldocSelect.ChildNodes;

foreach (XmlNode xn1 in nodeList)//遍历

{

XmlElement xm = (XmlElement)xn1;//转换类型

switch (xm.Name)

{

case "adLeftHeight":

xm.InnerText=txtLeftHeight.Text;

break;

case "adLeftHref":

xm.InnerText=txtLeftURL.Text;

break;

case "adLeftSrc":

xm.InnerText=txtadLeftSrc.Text;

break;

case "adLeftType":

if (RadioButton1.Checked == true)

{

xm.InnerText = "jpg";

}

else

{

xm.InnerText = "flash";

}

break;

case "adLeftWidth":

xm.InnerText=txtLeftWidth.Text;

break;

case "adRightHeight":

xm.InnerText=txtRightHeight.Text;

break;

case "adRightHref":

xm.InnerText = txtRightURL.Text;

break;

case "adRightSrc":

xm.InnerText=txtadRightSrc.Text;

break;

case "adRightType":

if (RadioButton3.Checked == true)

{

xm.InnerText = "jpg";

}

else

{

xm.InnerText = "flash";

}

break;

case "adRightWidth":

xm.InnerText=txtRightWidth.Text;

break;

case "marginTop":

xm.InnerText=txtTopMargin.Text;

break;

case "marginLeft":

xm.InnerText=txtLefyMargin.Text;

break;

}

}

xmlDoc.Save(Server.MapPath("~/CSS/AD.XML"));

LoadXml();

ReadXML();

Bind();

}

protected void btnCancel_Click(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

if (!(File1.PostedFile.ContentLength > 0))

{

Label1.Text = "请选择上传文件";

}

else

{

if (File1.PostedFile.ContentType == "image/pjpeg" || File1.PostedFile.ContentType == "application/x-shockwave-flash" || File1.PostedFile.ContentType == "image/gif")

{

string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf('\\') + 1);

string path = Server.MapPath("~/images/") + filename;

if (File.Exists(path))

{

Label1.Text = "文件已经存在!";

}

else

{

File1.PostedFile.SaveAs(path);

}

txtadLeftSrc.Text = "./images/" + filename;

Label1.Text = "文件上传成功!";

}

else

{

Label1.Text = "请选择图形文件或者Flash文件!";

}

}

XmlNode xmldocSelect = xmlDoc.SelectSingleNode("/Root/Content");

XmlNodeList nodeList = xmldocSelect.ChildNodes;

foreach (XmlNode xn1 in nodeList)//遍历

{

XmlElement xm = (XmlElement)xn1;//转换类型

if (xm.Name =="adLeftSrc")

{

xm.InnerText = txtadLeftSrc.Text;

}

}

xmlDoc.Save(Server.MapPath("~/CSS/AD.XML"));

adLeftSrc = txtadLeftSrc.Text;

}

protected void Button2_Click(object sender, EventArgs e)

{

if (!(File2.PostedFile.ContentLength > 0))

{

Label2.Text = "请选择上传文件";

}

else

{

if (File2.PostedFile.ContentType == "image/pjpeg" || File2.PostedFile.ContentType == "application/x-shockwave-flash" || File2.PostedFile.ContentType == "image/gif")

{

string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + File2.PostedFile.FileName.Substring(File2.PostedFile.FileName.LastIndexOf('\\') + 1);

string path = Server.MapPath("~/images/") + filename;

if (File.Exists(path))

{

Label2.Text = "文件已经存在!";

}

else

{

File2.PostedFile.SaveAs(path);

}

txtadRightSrc.Text = "./images/" + filename;

Label2.Text = "文件上传成功!";

}

else

{

Label2.Text = "请选择图形文件或者Flash文件!";

}

}

XmlNode xmldocSelect = xmlDoc.SelectSingleNode("/Root/Content");

XmlNodeList nodeList = xmldocSelect.ChildNodes;

foreach (XmlNode xn1 in nodeList)//遍历

{

XmlElement xm = (XmlElement)xn1;//转换类型

if (xm.Name == "adRightSrc")

{

xm.InnerText = txtadRightSrc.Text;

}

}

xmlDoc.Save(Server.MapPath("~/CSS/AD.XML"));

adRightSrc = txtadRightSrc.Text;

}

}

ad.xml

==================

<?xml version="1.0" encoding="utf-8"?>

<Root>

<Content>

<adLeftType>jpg</adLeftType>

<adLeftHref>http://www.gocean.com.cn</adLeftHref>

<adLeftWidth>98</adLeftWidth>

<adLeftHeight>218</adLeftHeight>

<adLeftSrc>./images/20070429114246logo.gif</adLeftSrc>

<adRightType>flash</adRightType>

<adRightHref>http://www.gocean.com.cn</adRightHref>

<adRightWidth>98</adRightWidth>

<adRightHeight>218</adRightHeight>

<adRightSrc>./images/20070429102841map.swf</adRightSrc>

<marginTop>250</marginTop>

<marginLeft>1</marginLeft>

</Content>

</Root>

==========================================================

AD.XML 保存有相关配置信息(图片(flash)路径)

ad6.js 为生成的JS文件

在需要浮动广告的页面配置 引用Js文件