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 id="form1" runat="server">
<div id="content">
<table id="detail">
<tr>
<th class="outer_color outer_size">首页浮动广告管理</th>
</tr>
<tr>
<td style=" 756px"></td>
</tr>
<tr>
<td>
<table class="table_with_border">
<tr>
<th colspan="6">
广告信息:
</th>
</tr>
<tr>
<td colspan="6">
<asp:Button ID="btnAdd" runat="server" Text="保 存" OnClick="btnAdd_Click" CssClass="button" />
<asp:Button ID="btnCancel" runat="server" CssClass="button" OnClick="btnCancel_Click" Text="重 置" />
<asp:Button ID="btnCreateJS" runat="server" CssClass="button" Text="生成JS" OnClick="btnCreateJS_Click" /></td>
</tr>
<tr>
<td style=" 293px">
左边广告类型</td>
<td colspan="3" style=" 378px">
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="leftType" Text="图片" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="leftType" Text="Flash" /></td>
<td colspan="1" style=" 370px">
右边广告类型</td>
<td colspan="1" style=" 370px">
<asp:RadioButton ID="RadioButton3" runat="server" GroupName="rightType" Text="图片" />
<asp:RadioButton ID="RadioButton4" runat="server" GroupName="rightType" Text="Flash" /></td>
</tr>
<tr>
<td style=" 293px">
上传图片或FLASH</td>
<td colspan="3" style=" 378px">
<asp:TextBox ID="txtadLeftSrc" runat="server" CssClass="textbox" ReadOnly="True"></asp:TextBox> <asp:Label
ID="Label1" runat="server" ForeColor="Red" Width="87px"></asp:Label><br />
<input id="File1" type="file" runat="server" />
<asp:Button ID="Button1" runat="server" Text="上传" CausesValidation="False" OnClick="Button1_Click" /></td>
<td colspan="1" style=" 370px">
上传图片或FLASH</td>
<td colspan="1" style=" 370px">
<asp:TextBox ID="txtadRightSrc" runat="server" CssClass="textbox" ReadOnly="True"></asp:TextBox>
<asp:Label ID="Label2" runat="server" ForeColor="Red" Width="99px"></asp:Label>
<input id="File2" type="file" runat="server" />
<asp:Button ID="Button2" runat="server" Text="上传" CausesValidation="False" OnClick="Button2_Click" /></td>
</tr>
<tr>
<td style=" 293px">
显示设置</td>
<td colspan="3" style=" 378px">
宽:<asp:TextBox ID="txtLeftWidth" runat="server" CssClass="textbox" Width="67px"></asp:TextBox><asp:RequiredFieldValidator
ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtLeftWidth"
Display="Dynamic" ErrorMessage="*必填"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
ID="RegularExpressionValidator3" runat="server" ControlToValidate="txtLeftWidth"
Display="Dynamic" ErrorMessage="*数字" ValidationExpression="^[0-9]+$"></asp:RegularExpressionValidator>高:<asp:TextBox
ID="txtLeftHeight" runat="server" CssClass="textbox" Width="74px"></asp:TextBox><asp:RequiredFieldValidator
ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtLeftHeight"
Display="Dynamic" ErrorMessage="*必填"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
ID="RegularExpressionValidator4" runat="server" ControlToValidate="txtLeftHeight"
Display="Dynamic" ErrorMessage="*数字" ValidationExpression="^[0-9]+$"></asp:RegularExpressionValidator></td>
<td colspan="1" style=" 370px">
显示设置</td>
<td colspan="1" style=" 370px">
宽:<asp:TextBox ID="txtRightWidth" runat="server" CssClass="textbox" Width="67px"></asp:TextBox><asp:RequiredFieldValidator
ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtRightWidth"
Display="Dynamic" ErrorMessage="*必填"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
ID="RegularExpressionValidator5" runat="server" ControlToValidate="txtRightWidth"
Display="Dynamic" ErrorMessage="*数字" ValidationExpression="^[0-9]+$"></asp:RegularExpressionValidator>高:<asp:TextBox
ID="txtRightHeight" runat="server" CssClass="textbox" Width="74px"></asp:TextBox><asp:RequiredFieldValidator
ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtRightHeight"
Display="Dynamic" ErrorMessage="*必填"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
ID="RegularExpressionValidator6" runat="server" ControlToValidate="txtRightHeight"
Display="Dynamic" ErrorMessage="*数字" ValidationExpression="^[0-9]+$"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td style=" 293px">
链接地址</td>
<td colspan="3" style=" 378px">
<asp:TextBox ID="txtLeftURL" runat="server" Width="202px"></asp:TextBox></td>
<td colspan="1" style=" 370px">
链接地址</td>
<td colspan="1" style=" 370px">
<asp:TextBox ID="txtRightURL" runat="server" Width="241px"></asp:TextBox></td>
</tr>
<tr>
<td style=" 293px; height: 20px;">
通用设置</td>
<td colspan="5" style="height: 20px">
上边距:<asp:TextBox ID="txtTopMargin" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTopMargin"
Display="Dynamic" ErrorMessage="*必填"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtTopMargin"
Display="Dynamic" ErrorMessage="*数字" ValidationExpression="^[0-9]+$"></asp:RegularExpressionValidator>边距:<asp:TextBox ID="txtLefyMargin" runat="server"></asp:TextBox><asp:RequiredFieldValidator
ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtLefyMargin"
Display="Dynamic" ErrorMessage="*必填"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtLefyMargin"
Display="Dynamic" ErrorMessage="*数字" ValidationExpression="^[0-9]+$"></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 id=\\\"adLeftFloat\\\" style=\\\"position: absolute;\\\" + 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 id=\\\"adLeftFloat\\\" style=\\\"position: absolute;\" + adLeftWidth + \";\\\"><a href=\\\"\" + adLeftHref +\"\\\"><img src=\\\"\" + adLeftSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\" border=\\\"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 id=\\\"adRightFloat\\\" style=\\\"position: absolute;\" + 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 id=\\\"adRightFloat\\\" style=\\\"position: absolute;\" + adRightWidth + \";\\\"><a href=\\\"\" + adRightHref +\"\\\"><img src=\\\"\" + adRightSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\" border=\\\"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 id=\\\"adLeftFloat\\\" style=\\\"position: absolute;\\\" + 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 id=\\\"adLeftFloat\\\" style=\\\"position: absolute;\" + adLeftWidth + \";\\\"><a href=\\\"\" + adLeftHref +\"\\\"><img src=\\\"\" + adLeftSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\" border=\\\"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 id=\\\"adRightFloat\\\" style=\\\"position: absolute;\" + 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 id=\\\"adRightFloat\\\" style=\\\"position: absolute;\" + adRightWidth + \";\\\"><a href=\\\"\" + adRightHref +\"\\\"><img src=\\\"\" + adRightSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\" border=\\\"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 id=\\\"adLeftFloat\\\" style=\\\"position: absolute;\\\" + 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 id=\\\"adLeftFloat\\\" style=\\\"position: absolute;\" + adLeftWidth + \";\\\"><a href=\\\"\" + adLeftHref +\"\\\"><img src=\\\"\" + adLeftSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adLeftHeight + \"\\\" border=\\\"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 id=\\\"adRightFloat\\\" style=\\\"position: absolute;\" + 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 id=\\\"adRightFloat\\\" style=\\\"position: absolute;\" + adRightWidth + \";\\\"><a href=\\\"\" + adRightHref +\"\\\"><img src=\\\"\" + adRightSrc + \"\\\" width=\\\"\" + adLeftWidth + \"\\\" height=\\\"\" + adRightHeight + \"\\\" border=\\\"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文件