I want to read an app key from the web.config file via java script. The web.config key to be read
<appSettings>
<add key="Key1" value="value1" />
<appSettings>
I include the following inside my java script function.
function Evaluate() {
var key = '<%=ConfigurationManager.AppSettings["Key1"].ToString() %>';
alert(key);
}
However, I end up getting <%=ConfigurationManager.AppSettings["Key1"].ToString() %>
in the alert.
What am i missing?
The <%= =>
tag is only going to execute if it is within a .aspx
file. If you place it within a .js file, then it will just be like any other text. In order for your code to work, the javascript you posted would have to be embedded within the .aspx file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With