Posted by Praveen Kumar on April 5, 2008
ASP.NET provides the Web Site Administration Tool to view and manage the configuration settings for your ASP.NET website. These configuration settings are stored in an xml file called web.config.
“web.config is an application configuration file used to define configuration settings such as connecting strings, authentication, authorization etc., for an ASP.NET application”
Step 1: Create a new ASP.NET website. Add a button control to the Default.aspx.
Step 2: Right click the project > Add New Item > Web Configuration File
Add the following sample entries in the file between the <configuration> tag as shown below:
<addname=“MyConnString“connectionString=“Data Source=(local);Initial Catalog=Northwind;Integrated Security=True;“/>
var conn = ‘<%=ConfigurationManager.ConnectionStrings[“MyConnString”].ConnectionString %>’
var v1 = ‘<%=ConfigurationManager.AppSettings[“var1”].ToString() %>’
Step 4: Call this function on a button click and display the values of the configuration settings
<asp:Button ID=”Button1″ runat=”server” Text=”Button”OnClientClick=”ReadConfigSettings()” /></div>
That’s it. Run the application and click the button. The values of the configuration settings in the web.config will be displayed in the alert boxes.
I hope you liked this short article and I thank you for viewing it. If you liked the article,
then please comment it or give me suggestion to make more effective.