เพื่อนสามารถทดสอบได้ด้วยตัวเอง
ใช้ระบบ
ใช้ 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
-
Protected System.web.ui.webcontrols.TextBox TextBox1;
Protected System.web.ui.webcontrols.dropdownlist DropdownList1;
Protected System.web.ui.webcontrols.button button1;
เว็บฟอร์มสาธารณะ 1 ()
-
pay.init += ใหม่ system.eventhandler (page_init);
-
โมฆะส่วนตัว page_load (ผู้ส่งวัตถุ, system.eventargs e)
-
if (! page.ispostback)
-
// เปิดไฟล์ (สมมติว่า web.config อยู่ในไดเรกทอรีรูท)
String filename = server.mappath (/) + @/web.config;
xmldocumentxmldoc = ใหม่ xmldocument ();
xmldoc.load (ชื่อไฟล์);
XmlNodelist topm = xmldoc.documentedlement.childnodes;
foreach (องค์ประกอบ xmlelement ใน topm)
-
if (element.name.tology () == AppSettings)))
-
xmlnodelist_node = element.childnodes;
ถ้า (_node.count> 0)
-
DropdownList1.items.Clear ();
foreach (xmlelement el ใน _node)
-
DropdownList1.items.add (el.attributes [key] .innerxml);
-
-
-
-
-
-
โมฆะส่วนตัว PAGE_INIT (ผู้ส่งวัตถุ EventArgs E)
-
เริ่มต้น ();
-
#REGION Web Form Designer สร้างรหัส
/// <summary>
/// วิธีการที่จำเป็นสำหรับการสนับสนุนนักออกแบบ -อย่าแก้ไข
/// เนื้อหาของวิธีนี้กับตัวแก้ไขรหัส
/// </summary>
โมฆะส่วนตัวเริ่มต้นคอมเม้นต์ ()
-
this.button1.click += ใหม่ System.eventHandler (this.button1_click);
this.load += new System.eventHandler (this.page_load);
-
#endregion
โมฆะส่วนตัว button1_click (ผู้ส่งวัตถุ, system.eventargs e)
-
String filename = server.mappath (/) + @/web.config;
xmldocumentxmldoc = ใหม่ xmldocument ();
xmldoc.load (ชื่อไฟล์);
XmlNodelist topm = xmldoc.documentedlement.childnodes;
foreach (องค์ประกอบ xmlelement ใน topm)
-
if (element.name.tology () == AppSettings)))
-
xmlnodelist_node = element.childnodes;
ถ้า (_node.count> 0)
-
foreach (xmlelement el ใน _node)
-
if (el.attributes [key] .innerxml.tology () == this.dropdownlist1.SelectedItem.value.toLower ())
-
El.attributes [ค่า]
-
-
-
-
-
xmldoc.save (ชื่อไฟล์);
-
-
-