如何动态修改web.config中pages节点中theme值?1 <configuration>
2 <configSections>
3 </configSections>
4 <appSettings/>
5 <system.web>
6 <pages theme="Aqua">
7 </pages>
8 </system.web>
9 </configuration> 注:新建一页面,在text文本框中输入值后,点击修改,即可修改成功。如何实现这个功能。求助……
2 回答

吃鸡游戏
TA贡献1829条经验 获得超7个赞
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"));
测试过

蓝山帝景
TA贡献1843条经验 获得超7个赞
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); }
- 2 回答
- 0 关注
- 746 浏览
添加回答
举报
0/150
提交
取消