NealR
NealR

Reputation: 10709

Access app.config values in Javascript

I need to fill a variable with a value from the app.config. Is there a way to do this in Javascript? This is what I have right now, however I don't believe it's in any way correct..

var notConfident = ConfigurationManager.AppSettings["GoogleValue"];

Upvotes: 0

Views: 3949

Answers (1)

lolol
lolol

Reputation: 4390

No, javascript runs in the client side browser, the app config is a file in the server.

You can get the value by sending it to the client side, something like:

.aspx file:

<input type="hidden" id="ikey" runat="server" />

.cs file, page load method:

ikey.InnerText = ConfigurationManager.AppSettings["GoogleValue"];

.js file, onload method:

var something = document.getElementById("ikey").value;

Upvotes: 2

Related Questions