I’m trying to create a function that retrieves a web.config app settings value. This works if I put the code alert('<%=ConfigurationManager.AppSettings["facebookAppID"].ToString() %>') in the .ascx file directly. But if I call a common function in a .js file from that .ascx file (so as to have a common global function), it doesn’t work…i.e. it doesn’t evaluate the value but instead just returns the string “<%=System.ConfigurationManager.AppSettings[\”facebookAppID\”].ToString(); %>”
Any thoughts as to why this is?
function GetappId() {
var k = "<%=System.ConfigurationManager.AppSettings["facebookAppID"].ToString(); %>"
alert(k);
return k
}
Common .js files if your including them like this script src=”somescript.js” /script are loaded on the clients browser and are never processed on the server.
Only way to load files/values using javascript would be to perform and ajax call to an aspx page that returns either JSON or text..
http://api.jquery.com/jQuery.ajax/