How to access the ASP.NET configuration settings.
If you had the following information in your web.config file. How would you access this information. The idea is to have this information in one place within your application and you can now spread this information to multiple areas on your application. If you then have to change the information you only have to change it in one place as opposed to changing it in multiple places.
<appSettings>
<add key="myConnectionString" value="theConnectionStringWouldGoHere" />
</appSettings>
label1.Text = ConfigurationManager.AppSettings("myConnectionString");
If you ran this the label would have the value of the appSettings configuration. You can now use this feature in your code behind to bind to your connection string in your web.config file.
Another way to set the connection string.
<connectionStrings>
<add name="myConnectionString" connectionString="thisIsWhereTheConnectionStringGoes" />
</connectionStrings>
To call this connection string from the code you use syntax that is similar to the appSettings syntax
label.Text = ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString;