If you have scripts that are specific to certain pages, and you use one main MasterPage
, simply add a ContentPlaceHolder
in the head of the master page.
Masterpage:
<head runat="server">
<script type="text/javascript" src="my-site-wide-script.js"></script>
<asp:ContentPlaceHolder ID="cphHead" runat="server" />
</head>
content page:
<asp:content ID="cHead" runat="server" ContentPlaceHolderID="cphHead">
<script type="text/javascript" src="some-page-specific-script.js"></script>
</asp:content>
End result served to browser (in general):
<head>
<script type="text/javascript" src="my-site-wide-script.js"></script>
<script type="text/javascript" src="some-page-specific-script.js"></script>
</head>
Now any scripts you add to your content page will be after your base scripts. Gives you the flexibility to have page-specific scripts.
And note: VS2005 will throw up a warning/error that ContentPlaceHolder
isn't allowed within the head tag. Ignore it, it's a bug in VS. VS2008+ will not bother you about it.