标签:
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();
}
标签:
原文地址:http://www.cnblogs.com/xusy/p/4832082.html