友達は自分でそれをテストすることができます。
システムの使用。
System.Collectionsを使用します。
System.comPonentModelを使用しています。
System.Dataを使用しています。
System.drawingを使用しています。
system.webを使用しています。
System.Web.SessionStateを使用しています。
system.web.uiを使用しています。
System.Web.ui.WebControlsを使用します。
System.web.ui.htmlControlsを使用します。
System.xmlを使用しています。
名前空間WebApplication1
{{
/// <summary>
/// webform1の概要説明。
/// </summary>
パブリッククラスWebForm1:System.Web.ui.page
{{
保護されたSystem.Web.ui.WebControls.TextBox TextBox1;
保護されたSystem.Web.ui.WebControls.DropDownList DropDownList1;
保護されたSystem.web.ui.webcontrols.button button1;
public webform1()
{{
pay.init += new System.EventHandler(page_init);
}
private void page_load(object sender、system.eventargs e)
{{
if(!page.ispostback)
{{
//ファイルを開きます(web.configがルートディレクトリにあると仮定します)
文字列filename = server.mappath(/) + @/web.config;
xmldocumentxmldoc = new xmldocument();
xmldoc.load(filename);
xmlnodelist topm = xmldoc.documentedlement.childnodes;
foreach(topmのxmlelement要素)
{{
if(element.name.tology()== appsettings))
{{
xmlnodelist_node = element.childnodes;
if(_node.count> 0)
{{
dropdownlist1.items.clear();
foreach(_nodeのxmlelement el)
{{
dropdownlist1.items.add(el.attributes [key] .innerxml);
}
}
}
}
}
}
private void page_init(オブジェクト送信者、eventargs e)
{{
initializeComponent();
}
#region Webフォームデザイナー生成コード
/// <summary>
///デザイナーサポートに必要な方法 - 変更しないでください
///コードエディターを使用したこのメソッドの内容。
/// </summary>
private void initializeComponent()
{{
this.button1.click += new System.EventHandler(this.button1_click);
this.load += new System.EventHandler(this.page_load);
}
#endregion
private void button1_click(object sender、system.eventargs e)
{{
文字列filename = server.mappath(/) + @/web.config;
xmldocumentxmldoc = new xmldocument();
xmldoc.load(filename);
xmlnodelist topm = xmldoc.documentedlement.childnodes;
foreach(topmのxmlelement要素)
{{
if(element.name.tology()== appsettings))
{{
xmlnodelist_node = element.childnodes;
if(_node.count> 0)
{{
foreach(_nodeのxmlelement el)
{{
if(el.attributes [key] .innerxml.tology()== this.dropdownlist1.selecteditem.value.tolower()))
{{
el.Attributes [value] = this.textbox1.text;
}
}
}
}
}
xmldoc.save(filename);
}
}
}