ASP.NET (35) SQL (25) JAVASCRIPT (24) HTML (14) STYLE SHEET (6) ASP (4) SCRIPT (1)

Search me out HERE!!

TO USE GLOBAL PARAMETER FROM WEB.CONFIG FILE

Below mention is code to access Connection string from Web.Config file. Here you can have multiple variables.

Write this in Web.Config file :


<configuration> 
  <appSettings> 
     <add key="ConnectionString" value="server=localhost;uid=sa;pwd=;database=DBPerson" /> 
  </appSettings>
</configuration>

//Here value is Connection String used to connect with database
 Now you can access above value in your web page as given below: 
using System.Configuration;
string connectionString = ConfigurationSettings.AppSettings["ConnectionString"].ToString();


Note:Similarly you can add multiple KEY which you want as global variable.

No comments:

Post a Comment