【发布时间】:2012-05-01 17:52:47
【问题描述】:
我正在开发一个 Web 表单站点。头标签具有 runat 服务器属性。在母版页中。
我正在尝试将 ResolveClientUrl 用于这样的 .js 文件:
<head runat="server">
..
<script src='<%= ResolveClientUrl("~/myscript.js") %>' type="text/javascript" > </script>
</head>
然后,我得到了一个错误:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
我发现问题出在 runat 服务器上,所以我将它从 head 标记中删除...现在我收到以下错误:
Using themed css files requires a header control on the page. (e.g. <head runat="server" />).
那么,如何在 runat 服务器头中使用 ResolveClientUrl?
更新:
我已经在母版页顶部使用包含添加了脚本(似乎工作正常).. 但可能有更好的解决方案。
<!-- #include file="myscript.js" -->
【问题讨论】:
标签: asp.net webforms runatserver resolveclienturl