Preferred way to include relative reference to JavaScript in VS 2008 nested Masterpage(在 VS 2008 嵌套 Masterpage 中包含对 JavaScript 的相对引用的首选方法)
问题描述
我们的基础 Masterpage 有如下内容
Our base Masterpage has something like the following
<head runat="server">
<title></title>
<script type="text/javascript" src="Jmx0OyU9IFBhZ2UuUmVzb2x2ZUNsaWVudFVSTCg="~/javascript/actions.js")%>"></script>
<script type="text/javascript" src="Jmx0OyU9IFBhZ2UuUmVzb2x2ZUNsaWVudFVSTCg="~/javascript/jquery/jquery-1.2.6.min.js")%>"></script>
<asp:contentplaceholder id="cph_htmlhead" runat="server">
</asp:contentplaceholder>
</head>
如果此 Masterpage 是 ASPX 页面的 Masterpage,则一切正常.
If this Masterpage is the Masterpage for an ASPX page things work fine.
如果此母版页是子母版页的母版页,然后新的 ASPX 页面使用子母版页,就像我们看到的母版页一样:
If this Masterpage is the Masterpage for a child Masterpage and then a new ASPX page uses the child Masterpage as it's MasterPage we see:
应用程序"中的服务器错误.
Server Error in '' Application.
无法修改 Controls 集合,因为该控件包含代码块(即 <% ... %>).
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
在保留波浪号 (~) 样式相对路径的基本 Masterpage 中包含全局资源 (Javascript/CSS) 的首选方法是什么?
推荐答案
使用 ScriptManager 服务器控件:
Use the ScriptManager server control:
<asp:ScriptManager ID="myScriptManager" runat="server">
<Scripts>
<asp:ScriptReference Path = "~/javascript/actions.js" />
<asp:ScriptReference Path = "~/javascript/jquery/jquery-1.2.6.min.js" />
</Scripts>
</asp:ScriptManager>
这篇关于在 VS 2008 嵌套 Masterpage 中包含对 JavaScript 的相对引用的首选方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 VS 2008 嵌套 Masterpage 中包含对 JavaScript 的相对


- 在 LINQ to SQL 中使用 contains() 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
- 使用 rss + c# 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01