问题
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>
how I do work ?
回答1:
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>
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>
回答2:
Just simply defined the js file link in your content page inside the Head content place holder and it will overload the previous one.
来源:https://stackoverflow.com/questions/18719082/how-to-replace-the-jquery-library-set-in-the-masterpage-from-a-content-page