This tutorial will show you how to get connectionstring from configuration file using ASP.NET 2.0 and C#. At first, please import the namespace from System.Configuration.

The System.Configuration namespace contains classes that represents a configuration file applicable to a particular computer, application, or resource.

In order to show the result of the sample, we will use the btn_GetConn_Click and GetConnectionString to perform the task. The sample code as following:

The front end page looks something like this:

The front end SeekConnectionStringCsharp.aspx page looks something like this:

The flow for the code behind page is as follows

Download Source Files