title: passing javascript variable in app.settings (client side variable to server side)
body: <blockquote>
    <p>I want to read the config file in javascript that is the google key
    value. here what i am trying to do is passing a javascript
    variable"keyvalue" that is the keyname in config file but it does not
    work. i just want it so that the js function automatically picks up
    the google key according to site URL whether it may be test or dev or
    qa.abc.com can anyone help me what should i do to read the value form
    config file.</p>
  </blockquote>
  
  <pre><code>  &lt;script type="text/javascript"&gt;
  
  function ReadConfigSettings()
  { 
  
  var url="test.abc.com"; //window.location.href
  
  var patharray= new Array();
  
  patharray =url.split('.');
  
  var first = patharray[0];
  
   var keyvalue="GoogleKey_"+ first;
  
   var key='&lt;%=ConfigurationManager.AppSettings[keyvalue]%&gt;';
  
   alert(key);
  }
  
   &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
  
          &lt;asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ReadConfigSettings()" /&gt;
  
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <blockquote>
    <p>my config file</p>
  </blockquote>
  
  <pre><code>&lt;appSettings&gt;
      &lt;add key="GoogleKey_dev" value="ABQIAAAAJ4psDZ8kCtN062-LDcwiXhQ85a215fgrIsfghh547457h1ETJRYlwaBGrrytgytg56g7Mx4QFQ"/&gt;
      &lt;add key="GoogleKey_qa" value="ABQIAAAACoUjxmFCsPtytryhtyty547547Ryt5gVV28BYSHIaU0BRwPyLrf_gf546Jd_5qxcNZ-_b7WZw"/&gt;
      &lt;add key="GoogleKey_test" value="AIzaSyvbghgfyh54654650x2SlGb33KrTtIBc"/&gt;
  </code></pre>