选择显示字体大小

asp.net中动态修改web.config中的设置项目(cs页代码)


朋友们可以自行测试,我这里都没有问题了,鳖了一上午的问题总算解决了

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
{
/// <summary>
/// summary description for webform1.
/// </summary>
public class 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;

public webform1()
{
page.init += new system.eventhandler(page_init);
}

private void page_load(object sender, system.eventargs e)
{
if(!page.ispostback)
{
//打开某文件(假设web。config在根目录中)
string filename=server.mappath(&quot;/&quot;) + @&quot;\web.config&quot;;
xmldocument xmldoc= new xmldocument();
xmldoc.load(filename);

xmlnodelist topm=xmldoc.documentelement.childnodes;
foreach(xmlelement element in topm)
{
if(element.name.tolower()==&quot;appsettings&quot;)
{
xmlnodelist _node=element.childnodes;
if ( _node.count >0 )
{
dropdownlist1.items.clear();
foreach(xmlelement el in _node)
{
dropdownlist1.items.add(el.attributes[&quot;key&quot;].innerxml);
}
}
}
}
}
}

private void page_init(object sender, eventargs e)
{
initializecomponent();
}

#region web form designer generated code
/// <summary>
/// required method for designer support - do not modify
/// the contents of this method with the code editor.
/// </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)
{
string filename=server.mappath(&quot;/&quot;) + @&quot;\web.config&quot;;
xmldocument xmldoc= new xmldocument();
xmldoc.load(filename);

xmlnodelist topm=xmldoc.documentelement.childnodes;
foreach(xmlelement element in topm)
{
if(element.name.tolower()==&quot;appsettings&quot;)
{
xmlnodelist _node=element.childnodes;
if ( _node.count >0 )
{
foreach(xmlelement el in _node)
{
if(el.attributes[&quot;key&quot;].innerxml.tolower()==this.dropdownlist1.selecteditem.value.tolower())
{
el.attributes[&quot;value&quot;].value=this.textbox1.text;
}
}
}
}
}
xmldoc.save(filename);
}
}
}

  


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons