
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>");
}
}
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步