asp.net - web.config variable declaration and use in javascript -


how define variable in web.config file , make use of same in javascript code?

i made try assigning key value pair seems not working!

you should pass variable web.config js file via code-behind. example, let's variable named my-variable. web.config should :

<configuration>  <appsettings>     <add key="my-variable" value="my-value" />   </appsettings> </configuration> 

your aspx file can , send js :

protected void page_load(object sender, eventargs e) {     clientscriptmanager csm = page.clientscript;     type cstype = this.gettype();     string myvariable = configurationmanager.appsettings["my-variable"].tostring();      // add script current page before end tag </form>     csm.registerstartupscript(cstype,          "initvariable",          string.format("window.myvariable = '{0}';", myvariable, true); } 

and js, can use variable myvariable.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -