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"]
<scripttype="text/javascript">
function ReadConfigurationSettings()
{
var k = '<%=ConfigurationManager.AppSettings["var1"].ToString() %>'
alert(k);
}
</script>
Member
4 Points
61 Posts
web.config key in javascript
Apr 23, 2007 08:10 PM|mayuresh_s|LINK
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
ConfigurationElementCollection ConfigurationSection asp.net web.config web.config C# web.config C# ASP.net webdeploymentproject ASP.NET 2.0 deploy web.config ajax c# website deploy ASP and Web.config connection string SQL schema database web.config deploy web.config godaddy
Member
503 Points
581 Posts
Re: web.config key in javascript
Apr 23, 2007 11:04 PM|deepak.vasudevan|LINK
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%>" ;
Deepak Vasudevan
http://www.lavanyadeepak.tk/
-------
Member
4 Points
61 Posts
Re: web.config key in javascript
Apr 24, 2007 11:48 AM|mayuresh_s|LINK
Member
13 Points
29 Posts
Re: web.config key in javascript
Nov 21, 2008 06:00 AM|vaibhavgangal|LINK
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
None
0 Points
1 Post
Re: web.config key in javascript
Dec 01, 2009 04:39 PM|virang_21|LINK
This is cool....
Thank You very much...
Good start of my day....
Member
21 Points
37 Posts
Re: web.config key in javascript
Nov 06, 2013 01:15 AM|velayudham|LINK