我正试图在母版页中添加对jQuery的脚本引用,以便它可以用于任何页面.现在看起来是这样的
<script type="text/javascript" src="jquery.js"></script>
The problem is that the path is always relative to the executing aspx page so this will only work if the "jquery.js" file is located in the same folder. To make it work I have to change the line to:
<script type="text/javascript" src="../../jquery.js"></script>
这显然不太理想,因为它只适用于距离根文件夹两级深的页面.如果我try 执行以下操作,IIS将引发有关意外字符的错误.
<script runat="server" type="text/javascript" src="~/jquery.js"></script>
有什么 idea 吗?
EDIT:.我还忘了提到 playbook 必须放在头标签上
The current top answer throws a "ASP.NET Ajax client-side framework failed to load." error when I add it to my master page. Its thrown from javascript and not the .Net compiler. If I move the ScriptManager to the head section where it should be I get a compile error about the ScriptManager needing to be inside a form tag.
The third answer throws a "Illegal characters in path." exception from the compiler
EDIT 2:当我把这一行添加到我的头标签时,我从IIS中得到了这个错误.
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
SOLVED:我从下面的答案中获取经过编辑的答案,并将其放入asp:ContentPlaceHolder元素中