标记问题中的 AppSettings
我试图将其放入我的标记中:
<script type="text/javascript" src="<%$ AppSettings:proxyScriptUrl %>"></script>
但由于某种原因,这不被接受。我在这里做错了什么?
要求是我不使用辅助方法,但在标记中使用表达式构建器。
I am trying to put this in my markup:
<script type="text/javascript" src="<%$ AppSettings:proxyScriptUrl %>"></script>
But for some reason this is not accepted. What am I doing wrong here?
The requirement is that I do not use a helper method but that the expressionbuilder is used in the markup.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据文档,这是不允许的:
如果想在 aspx 文件中完成所有操作,这可能会帮助您:
注意文本变量中令人不快的单引号 - 尝试使用转义的双引号引号会导致“格式错误的脚本标记”错误。
编辑:抱歉 - 我已经交换了顺序,这确实有效。
According to the documentation, that's not allowed:
This might help you if want to do it all in the aspx file:
Note the unpleasant single quotes in the text variable - trying to us escaped double quotes results in "Badly formed script tag" errors.
Edit: apologies - I've swapped the order around this does work.
当我这样做时,我通常会创建一个帮助器类,我喜欢调用 Config 并在其中为相关的应用程序设置放置一个静态属性。
那么您的代码将变为:
这样做的其他一些好处是,如果我决定将 ProxyScriptUrl 移至不同的配置机制,我只需修改一个类。您的配置类可能如下所示:
When I do this I usually create a helper class I like to call Config and put a static property on there for the App Settings in question.
Then your code would become:
Some of the other benefits of this is that if I decide to move the ProxyScriptUrl to a different configuration mechanism I only have to modify the one class. Your config class might look like: