Os amigos podem testá -lo sozinho.
usando o sistema;
usando System.Collections;
usando o System.comPonsonModel;
usando System.data;
usando System.Drawing;
usando System.Web;
usando System.Web.SessionState;
usando system.web.ui;
usando o System.web.ui.webcontrols;
usando o System.web.ui.htmlControls;
usando System.xml;
namespace webApplication1
{{
/// <summary>
/// Descrição do resumo para WebForm1.
/// </summary>
Classe Public WebForm1: System.web.ui.page
{{
System.web.ui.webcontrols.textbox
Protegido 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 (remetente do objeto, System.Eventargs e)
{{
if (! Page.ispostback)
{{
// Abra um arquivo (suponha que o web.config esteja no diretório raiz)
string filename = server.mappath (/) + @/web.config;
xmldocumentxmldoc = new Xmldocument ();
xmldoc.load (nome do arquivo);
Xmlnodelist topm = xmldoc.documentEdled.childnodes;
Foreach (elemento XMLELEMENT no TOPM)
{{
if (element.name.tology () == appSsettings))
{{
Xmlnodelist_node = element.childnodes;
if (_node.count> 0)
{{
Suspenso listado1.items.clear ();
Foreach (xmlelement el em _node)
{{
DOLTOWNLIST1.Items.add (El.attributes [key] .innerxml);
}
}
}
}
}
}
Private void page_init (remetente de objeto, EventArgs e)
{{
inicializeComponent ();
}
#Region Web Form Designer Código gerado
/// <summary>
/// Método necessário para suporte ao designer -não modifique
/// O conteúdo deste método com o editor de código.
/// </summary>
Private vazio inicializecomponent ()
{{
this.Button1.Click += new System.EventHandler (this.Button1_Click);
this.load += new System.EventHandler (this.page_load);
}
#Endregion
Private Void Button1_Click (remetente de objeto, System.EventArgs e)
{{
string filename = server.mappath (/) + @/web.config;
xmldocumentxmldoc = new Xmldocument ();
xmldoc.load (nome do arquivo);
Xmlnodelist topm = xmldoc.documentEdled.childnodes;
Foreach (elemento XMLELEMENT no TopM)
{{
if (element.name.tology () == appSsettings))
{{
Xmlnodelist_node = element.childnodes;
if (_node.count> 0)
{{
Foreach (xmlelement el em _node)
{{
If (el.attributes [key] .innerxml.tology () == this.dropdownList1.SelectedItem.value.tolower ())
{{
el.attributes [valor].
}
}
}
}
}
xmldoc.save (nome do arquivo);
}
}
}