如何動(dòng)態(tài)修改web.config中pages節(jié)點(diǎn)中theme值?1 <configuration>
2 <configSections>
3 </configSections>
4 <appSettings/>
5 <system.web>
6 <pages theme="Aqua">
7 </pages>
8 </system.web>
9 </configuration> 注:新建一頁(yè)面,在text文本框中輸入值后,點(diǎn)擊修改,即可修改成功。如何實(shí)現(xiàn)這個(gè)功能。求助……
2 回答

吃雞游戲
TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊
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"));
測(cè)試過(guò)

藍(lán)山帝景
TA貢獻(xiàn)1843條經(jīng)驗(yàn) 獲得超7個(gè)贊
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 關(guān)注
- 764 瀏覽
添加回答
舉報(bào)
0/150
提交
取消