首页 > Web开发 > 详细

ASP.NET添加、修改、删除web.config配置信息

时间:2015-09-23 15:00:29      阅读:200      评论:0      收藏:0      [点我收藏+]

1、导入命名空间?

using System.Configuration;

using System.Web.Configuration ;

2、输入代码?

protected void Page_Load(object sender, EventArgs e)

{

if (!Page.IsPostBack)

{

//保存在配置文件中

TextBox1.Text= WebConfigurationManager.AppSettings["xdsj"].ToString();

TextBox2.Text= WebConfigurationManager.AppSettings["zygs"].ToString();

}?

}

protected void Button1_Click(object sender, EventArgs e)

{

string xdsj = TextBox1.Text;

string zygs = TextBox2.Text;

int i;

//保存在配置文件中

Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);

//增加

config.AppSettings.Settings.Add("key", "Name");

//修改

config.AppSettings.Settings["xdsj"].Value = xdsj;

config.AppSettings.Settings["zygs"].Value = zygs;

config.Save();

}

ASP.NET添加、修改、删除web.config配置信息

原文:http://www.cnblogs.com/xusy/p/4832082.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!