如何从内容页面替换在MasterPage中设置的jQuery库? [英] How to replace the jQuery library set in the MasterPage, from a Content Page?
问题描述
我有这个问题 我的项目有一个母版页和一个内容页,我在母版页中有此代码
I have this problem My project has a master page and content pages, I have in Master Page this code
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
但是我只需要在一个内容页面中使用它
but i need use this in only one content page
<script type="text/javascript" src="js/jquery-1.5.2.min.js"></script>
我如何工作?
推荐答案
在您的母版页上,添加ContentPlaceHolder
来包装jQuery库脚本:
On your Master Page, add a ContentPlaceHolder
to wrap the jQuery library script:
<asp:ContentPlaceHolder ID="jqContentPlaceHolder" runat="server">
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
</asp:ContentPlaceHolder>
在使用默认库的每个内容页面上,您只要忽略ContentPlaceHolder
即可-不将其放在页面上,因为如果它存在且为空,那么您将没有任何jQuery库.
On every single Content Page that uses the default library, you just ignore the ContentPlaceHolder
- by not putting it on the page, because if it's there and it's empty, you'll have no jQuery library whatsoever.
对于页面,您需要一个不同的库,只需执行以下操作:
For the page you need a different library, just do this:
<!-- This will replace the default contents set on the Master Page -->
<asp:Content ID="Content1" ContentPlaceHolderID="jqContentPlaceHolder" runat="server">
<script type="text/javascript" src="js/jquery-1.5.2.min.js"></script>
</asp:Content>
这篇关于如何从内容页面替换在MasterPage中设置的jQuery库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!