我正在尝试将其放入我的标记中:
<script type="text/javascript" src="<%$ AppSettings:proxyScriptUrl %>"></script>
但由于某种原因,这不被接受。我在这里做错了什么?
要求是我不使用辅助方法,但在标记中使用表达式构建器。
最佳答案
根据documentation ,这是不允许的:
If you want to use an expression as a static value on your page or control, you use an expression as part of an ASP.NET server control. A typical strategy is to add a Literal control and set its Text property to an expression. For example, to place a copyright notice at the bottom of every page you could use the following:
<p align="center">
<asp:Literal runat="server" text="<%$ AppSettings: copyright %>"/>
</p>
如果想在 aspx 文件中完成所有操作,这可能会帮助您:
<script type='text/javascript' src='<asp:Literal id="literal1" runat="server" text="<%$ AppSettings: jsSource %>" />'></script>
请注意文本变量中令人不快的单引号 - 尝试转义双引号会导致“格式错误的脚本标记”错误。
<小时/>编辑:抱歉 - 我已经交换了顺序,这确实有效。
关于asp.net - 标记问题中的 AppSettings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1681892/