<!--Settings.cs-->
using Chagel.Configration.Data;
namespace Chagel.Configration
{
public class Settings:IConfigurationSectionHandler
{ //实现该接口的Create方法
public object Create(object parent, object input, XmlNode node)
{
Data data = new Data();
<!--Data.cs-->
namespace Chagel.Configration.Data
{
public class Data
{
public Data()
{
}
public string AppName;//程序名称
public string AppVer;//程序版本
public string AppAuthor;//程序作者
... ...
}
}
至此,现在可以读取配置元素值了,如:
<!--Sample1.aspx-->
private void Page_Load(object sender, System.EventArgs e)
{
Data data;
data = ConfigurationSettings.GetConfig("mySection") as Data;
this.tbName.Text = data.AppName;
}