Reception code
<% @ Page language = "c #" codebehind = "Webform1.aspx.cs" autoeventwireup = "false" inherits = "WebApplication1.webform1"%>
head>CS page code
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls ; using System.Web.UI.HtmlControls; using System.Xml; namespace WebApplication1 {///
Public Webform1 () {page.init = new system.eventhandler (Page_init);
Private void page_load (object sender, system.eventargs e) {if (! page.ispostback) {// Open a file (assuming web.config in the root directory) String filename = server.mAppath ("/") @ " /Web.config"; xmldocument xmldoc = new xmldocument (); xmldoc.load (filename);
XmlNodeList topM = xmldoc.DocumentElement.ChildNodes; foreach (XmlElement element in topM) {if (element.Name.ToLower () == "appsettings") {XmlNodeList _node = element.ChildNodes; if (_node.Count> 0) {DropDownList1 .Items.clear (); foreach (xmlelement el in _node) {DropDownList1.items.add (el.attributes ["key"]. Innerxml;}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
Private void Page_init (Object Sender, Eventargs E) {INITIALIZEComponent ();
#region Web Form Designer generated code ///
} #endregion
private void Button1_Click (object sender, System.EventArgs e) {string filename = Server.MapPath ( "/") @ "/ web.config"; XmlDocument xmldoc = new XmlDocument (); xmldoc.Load (filename); 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.tolower () == this.dropdownList1.selectedItem.Value.tolower ()) {el.attributes ["value"]. value = this.TextBox1 .Text;}}}}} xmldoc.save (filename);}}}