Hello All:
I have a classic web forms asp (vb) web application that I am working with. I have one page that I would like to embed a value from my web.config's app.settings. this page references an external js file. What I am ultimately trying to do is pass the value from app.settings to the js file on an onclick event. The app.settings key holds the value of the current server, so I have transforms set to update the web.config with the correct server name when the application runs.
So in my app.settings I have:
<add key="CurrentServer" value="ProductionServer"/>
What I was trying to do was something like this:
<input type="hidden" id ="CurrentServer" value="<%$ AppSettings: CurrentServer %>" />
My reasoning behind this approach is then in the external file, I could target this input by doing something like:
let currentServer = document.getElementById('CurrentServer').value
When I run the page, I receive the following error:
Literal expressions like '<%$ AppSettings: CurrentServer %>' are not allowed. Use <asp:Literal runat="server" Text="<%$ AppSettings: CurrentServer%>" /> instead.
Can someone please steer me in the right direction? Would a server control be more appropriate? If so, how would I interrogate the rendered control using JavaScript once the onclick even is fired that triggers the javascript code?
Many thanks for any assistance!
Juan