XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("web.config"));
xmlDoc.SelectSingleNode("configuration").SelectSingleNode("system.web").SelectSingleNode("pages").Attributes["theme"].Value = "abc";
xmlDoc.Save(Server.MapPath("web.config"));
测试过
protected void btnTheme_Click(object sender, EventArgs e)
{
Configuration webConfig = WebConfigurationManager.OpenWebConfiguration("~");
((PagesSection)(webConfig.GetSectionGroup("system.web").Sections["pages"])).Theme = “MyTheme”;
webConfig.Save(ConfigurationSaveMode.Modified);
}