I have a asp.net c# webforms project. In the output html in the div “aspNetHidden” is a link to
<script src="/Scripts/jquery-1.8.2.js" type="text/javascript"></script>
I cannot figure out how to remove this code. It’s not in the master page file, and I can’t seem to find it anywhere. I would like to use a newer version of jquery, and place the reference at the bottom of the page instead.
I suspect it’s from one of the installed NuGet packages, but I can’t figure out which one, and I think i need them all.
EDIT:
If i create a new project and select ASP.NET Web Forms Application, the jquery link is there. I’m using visual studio express 2012.
EDIT 2: Found a solution – posted as an answer for others with similar problem to see.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I found a solution. It’s added by the scriptmanager, but can be overridden by adding the following in the global.asax. I don’t know if I can disable it completely, but this works for me.
string str = "1.10.2";
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
{
Path = "~/js/jquery-" + str + ".min.js",
DebugPath = "~/js/jquery-" + str + ".min.js",
CdnPath = "http://code.jquery.com/jquery-" + str + ".min.js",
CdnDebugPath = "http://code.jquery.com/jquery-" + str + ".min.js",
CdnSupportsSecureConnection = true
});
Method 2
I solve my problem by change version of jquery in packages.config
change
<package id="AspNet.ScriptManager.jQuery" version="1.8.2" targetFramework="net45" /> <package id="jQuery" version="1.8.2" targetFramework="net45" />
to
<package id="AspNet.ScriptManager.jQuery" version="2.1.4" targetFramework="net45" /> <package id="jQuery" version="2.1.4" targetFramework="net45" />
my jquery version is 2.1.4
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0