Tuesday, August 15, 2006

How to use web.config application settings

In your web.config file you can define a number of key/value settings and then access them from your web page. In your web.config file find appSettings and add the following key/value like this:

<appsettings>
<add key="FullName" value="Rush Frisby"/>
</appsettings>

In your aspx file create a label control called lblFullName. In your code behind file you can then say:
lblFullName.Text = ConfigurationSettings.AppSettings["FullName"];

1 comments:

Anonymous said...

Hi,
you could use System.Configuration.ConfigurationManager.AppSettings["property"]. In fact, it is recommended.