Asked by:
web.config key in javascript

Question
-
User165694579 posted
How can i access a web.config key in javascript. There is complex javascript function already written in a .js file and I need to add a value associated with the key - AUTHENTICATION_FLAG in a javascript function. I am coding this in C#. --- > ConfigurationManager.AppSettings["AUTHENTICATION_FLAG"]
Thank you in advance
Monday, April 23, 2007 8:10 PM
All replies
-
User-1041436249 posted
You need to read it in the codeBehind to a protected variable like
protected string strAppTitle = ConfigurationSettings.AppSettings["AppTitle"];
Then in the JavaScript, you can use
var strAppTitle = "<%=strAppTitle%>" ;
Monday, April 23, 2007 11:04 PM -
User165694579 posted
Thanks that worked.Tuesday, April 24, 2007 11:48 AM -
User-710233841 posted
Hi,
This worked really as expected. But what is logic or how it manages?
How is the protected variable accessible on client side?
Regards,
Vaibhav
Friday, November 21, 2008 6:00 AM -
User1519668543 posted
This is cool....
Thank You very much...
Good start of my day....
Tuesday, December 1, 2009 4:39 PM -
User-694384664 posted
<script type="text/javascript"> function ReadConfigurationSettings() { var k = '<%=ConfigurationManager.AppSettings["var1"].ToString() %>' alert(k); } </script>
Wednesday, November 6, 2013 1:15 AM