代码
using System;
using System.Xml;
public partial class Web_Admin_Admin_Basic : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sFile = Server.MapPath("../Web.config");
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(sFile);
XmlNodeList topm = xmldoc.DocumentElement.ChildNodes;
foreach (XmlElement element in topm)
{
if (element.Name.ToLower() == "appsettings")
{
XmlNodeList _node = element.ChildNodes;
if (_node.Count > 0)
{
foreach (XmlElement el in _node)
{
if (el.Attributes["key"].InnerXml == "IsOpenWin")
RadioButtonList1.SelectedValue = el.Attributes["value"].Value;
}
}
}
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string sFile = Server.MapPath("../Web.config");
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(sFile);
XmlNodeList topm = xmldoc.DocumentElement.ChildNodes;
foreach (XmlElement element in topm)
{
if (element.Name.ToLower() == "appsettings")
{
XmlNodeList _node = element.ChildNodes;
if (_node.Count > 0)
{
foreach (XmlElement el in _node)
{
if (el.Attributes["key"].InnerXml == "IsOpenWin")
el.Attributes["value"].Value = RadioButtonList1.SelectedValue;
}
}
}
}
xmldoc.Save(sFile);
Common.Message("<script>alert('修改成功');location.href='Admin_Basic.aspx'</script>");
}
}