ASP.NET 焦点图 示例

<object class  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="443" height="300">
        <param name="movie" value="images/bcastr31.swf" />
        <param name="quality" value="high" />
        <param name="wmode" value="transparent" />
        <param name="FlashVars" value="<%= DoImg() %>" />  
        <embed src="images/bcastr31.swf" FlashVars="<%= DoImg() %>" width="64%" height="300px" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" salign="T" name="scriptmain" menu="false" wmode="transparent"></embed></object>
public string DoImg()
    {
        string ImgString = string.Empty;
        string TitleString = string.Empty;
        string IDString = string.Empty;
        XPathDocument XPD = new XPathDocument(MapPath("~/FocusList.xml"));
        XPathNavigator XN = XPD.CreateNavigator();
        XPathNodeIterator XNI = XN.Select("/Image/Focus");
        while (XNI.MoveNext())
        {
            XNI.Current.MoveToFirstAttribute();
            IDString += "|NewsContent.aspx?id=" + XNI.Current.Value;
            XNI.Current.MoveToParent();
            XNI.Current.MoveToFirstChild();
            TitleString += "|" + XNI.Current.Value;
            XNI.Current.MoveToNext();
            ImgString += "|" + " " + XNI.Current.Value;
            XNI.Current.MoveToParent();
        }
        if (ImgString.Length > 1 && TitleString.Length > 1 && IDString.Length > 1)
        {
            string finalstring = "bcastr_file=" + ImgString.Remove(0, 1) + "&bcastr_link=" + IDString.Remove(0, 1) + "&bcastr_title=" + TitleString.Remove(0, 1) + "&bcastr_config=0xffffff:文字颜色|1:文字位置|0x99FF00:文字背景颜色|60:文字背景透明度|0xffffff:按键文字颜色|0x99FF00:按键默认颜色|0x000033:按键当前颜色|3:自动播放时间(秒)|1:图片过渡效果|1:是否显示按钮|_self:打开窗口";
            Response.Write(finalstring);
            return string.Empty;
        }
        else
        {
            return string.Empty;
        }
    }
///删

private void DelDoc(int DocID)

{

XmlDocument XD = new XmlDocument();

XD.Load(MapPath("~/FocusList.xml"));

XmlNode XN = XD.SelectSingleNode("Image");

XmlNode IC = XD.SelectSingleNode("/Image/*[@" + DocID.ToString() + "\"]");

if (IC != null)

{

XN.RemoveChild(IC);

XD.Save(MapPath("~/FocusList.xml"));

}

}

//添加

private void AddDoc(int NewsID, string NewsTitle, string ImgPath)

{

XmlDocument XD = new XmlDocument();

XD.Load(MapPath("~/FocusList.xml"));

XmlNode IRoot = XD.SelectSingleNode("Image");

XmlElement XE = XD.CreateElement("Focus");

XE.SetAttribute("ID", NewsID.ToString());

XmlElement ITitle = XD.CreateElement("Title");

ITitle.InnerText = NewsTitle;

XE.AppendChild(ITitle);

XmlElement IPath = XD.CreateElement("Path");

IPath.InnerText = ImgPath;

XE.AppendChild(IPath);

IRoot.AppendChild(XE);

XD.Save(MapPath("~/FocusList.xml"));

}

//xml

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

<Image>

<Focus >

<Title>团结湖中学课外活动丰富</Title>

<Path>UpImg/200865110700.jpg</Path>

</Focus>

</Image>