How to get appSetting values in .aspx file


Hi,

U can use app settings in aspx similar to connectionstrings in webconfig file

In your web config file

<appSettings>
<add key ="myKey" value ="myValue"/>
</appSettings>

In your aspx file

<asp:TextBox ID = "txtBox1" runat = "server" Text = "<%$appSettings:myKey %>" />

Similarly you can access appsettings values in javascript like this:

var my1 = ‘<%=ConfigurationManager.AppSettings["myKey"].ToString() %>’;

alert(my1);

Hope it helps

Advertisements

5 thoughts on “How to get appSetting values in .aspx file

  1. Hi,

    i need to concatenate the appsettings value with sqlquery.Like select column1 from appsettings.tablename
    How to achieve this?

    Thanks
    anuj

    • this is something like u want to create your sql query dynamically by fetching table name from appsettings ..right??

      so here is the example for that :

      string strQuery = “select * from ” + System.Configuration.ConfigurationSettings.AppSettings[“yourtablename”].ToString() ;

      hope this will help !!!

  2. Pingback: eating healthy diets

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s