How to Access AppSettings in ASPX or ASCX File


You have web application settings in the <appSettings> section of your web.config, and you want to access them in Web Form (.aspx) File or Web User Control (.ascx) file, you can use appSettings binding expression as shown in the following code.

Suppose you have following appSettings in web.config

<appSettings>
  <add key="LoginButtonText" value="Login" />
</appSettings>

You can read above appSettings in aspx or ascx file as follows:

<asp:Button id="Button1" runat="server" Text='<%$ appSettings:LoginButtonText %>'></asp:Button>

 

 

About author


User avatar

Waqas Anwar

Founder of EzzyLearning.com, Senior Consultant, Microsoft .NET and Web Technologies

Comments