Javascript文件-在运行时从web.config更改源

Javascript file - change source at runtime from web.config

本文关键字:config web 文件 运行时 Javascript      更新时间:2023-09-26

我的代码中有这个:

<script type="text/javascript"
  src="path?key=1234567890">
</script>

我在web.config中添加了这个:

<appSettings>
    <add key="key" value="1234567890"/>

如何在上面的代码中实现它?

使用System.Web.Configuration.WebConfigurationManager.AppSettings集合访问配置设置。

<script type="text/javascript"
        src="path?key=<%=WebConfigurationManager.AppSettings["key"]%>">
</script>