Accessing ConfigurationManager.AppSettings in Java script

前端 未结 1 1996
栀梦
栀梦 2021-01-29 03:01

I had this javascript code in aspx file

Page.aspx


 ----some code----
          


        
相关标签:
1条回答
  • 2021-01-29 03:33

    <%=ConfigurationManager.AppSettings["GAAccountId"]%> will work when you are using it in aspx file. It will not be evaluated when you are using it in external js file.

    You can do decalre a variable in aspx page

    <script type="text/javascript">
        var GAAccountId = '<%=ConfigurationManager.AppSettings["GAAccountId"]%>';
    </script>
    

    Use GAAccountId variable in JS File

    0 讨论(0)
提交回复
热议问题