ASP.Net Master Page and File path issues

You could use a ScriptManager:

<asp:ScriptManager ID="ScriptManager1" runat="server">
    <Scripts>
        <asp:ScriptReference Path="https://stackoverflow.com/questions/697660/~/jquery.js" />
    </Scripts>
</asp:ScriptManager>

EDIT: If you absolutely need this in your <head> section, you could do something like:

<head>
    <script type="text/javascript" 
        src="https://stackoverflow.com/questions/697660/<%= Page.ResolveClientUrl("https://stackoverflow.com/questions/697660/~/jquery.js") %>"></script>
</head>

EDIT 2: According to the comments, if you are observing that

The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>)

you may need to change the above to use the data-binding syntax:

<head>
    <script type="text/javascript" 
        src="<%# Page.ResolveClientUrl("https://stackoverflow.com/questions/697660/~/jquery.js") %>"></script>
</head>

Leave a Comment