Utilize the program dynamic management web.config file

xiaoxiao2021-04-09  436

Web.config file assumes that there is a configuration information you need to manage:

Implemented C # core code:

First, read information about Web.config into TextBox

private void Page_Load (object sender, System.EventArgs e) {if (! Page.IsPostBack) {Web.config correlation value // is populated TextBox this.txtTitle.Text = System.Configuration.ConfigurationSettings.AppSettings [ "SiteTitle "]; this.txtUrl.Text = System.Configuration.ConfigurationSettings.AppSettings [" SiteUrl "]; this.txtLogo.Text = System.Configuration.ConfigurationSettings.AppSettings [" SiteLogo "]; this.txtBanner.Text = System.Configuration .ConfigurationSettings.appsettings ["sitebanner"]; this.txtemail.text = system.configuration.configurationSettings.appsettings ["siteemail"];}

}

Second, write the modified content to Web.config

Private void btnsave_click (object sender, system.eventargs e) {string filename = server.mappath ("web.config"); string keyname; // key name

XmlDocument Xmldoc = new xmldocument (); try {xmldoc.load (filename);} catch {response.write ("