Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'jquery' is not a valid script name. The name must end in '.js'

Tags:

jquery

asp.net

My ASP.Net project is working well, when suddenly we had a power failure. When I ran my web app, it is now showing a lot of

Could not load assembly Sanitizer..." then "Could not load "HtmlAgility...

errors. I was able to resolve these previous errors by uninstalling / reinstalling them using Manage Nuget Package Solutions inside Visual Studio 2012.

But now I encountered another error:

'jquery' is not a valid script name. The name must end in '.js'."

I tried to do same thing by re-installing the package but it does not work. What should I do to resolve this? I already have a jquery.js file located on my root\Scripts folder. I also added reference to this file inside my section:

<script src="Scripts/jquery.js"></script>

But still it won't work. Please help.

like image 709
mstilapia Avatar asked Feb 20 '13 07:02

mstilapia


4 Answers

By the way guys, I was able to resolve this by installing the AspNet.ScriptManager.jQuery.UI.Combined and AspNet.ScriptManager.jQuery packages using the Nuget tool.

like image 59
mstilapia Avatar answered Nov 06 '22 01:11

mstilapia


Right click on your project and go to manage NuGet packages and then just install

AspNet.ScriptManager.jQuery.UI.Combined

and

AspNet.ScriptManager.jQuery

packages

like image 22
PK-1825 Avatar answered Nov 06 '22 03:11

PK-1825


Here is working solution

Open Global.asax in your solution

Copy below code just modify your Jquery Version accordingly and paste it inside Application_Start event of Global.asax

        ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
        {
            Path = "~/Scripts/jquery-1.10.2.min.js",
            DebugPath = "~/Scripts/jquery-1.10.2.js",
            CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.2.min.js",
            CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.2.js",
            CdnSupportsSecureConnection = true,
            LoadSuccessExpression = "window.jQuery"
        });

    ScriptManager.ScriptResourceMapping.AddDefinition("jquery.ui.combined", new ScriptResourceDefinition
    {
        Path = "~/Scripts/jquery-ui-1.10.2.min.js", 
        DebugPath = "~/Scripts/jquery-ui-1.10.2.js", 
        CdnPath = "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/jquery-ui.min.js", 
        CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/jquery-ui.js", 
        CdnSupportsSecureConnection = true
    });
         ScriptManager.ScriptResourceMapping.AddDefinition("bootstrap", new ScriptResourceDefinition
    {
        Path = "~/Scripts/bootstrap.min.js", 
        DebugPath = "~/Scripts/bootstrap.js", 
        CdnPath = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js", 
        CdnDebugPath = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js", 
        CdnSupportsSecureConnection = true
    });
like image 3
AirCode One Avatar answered Nov 06 '22 01:11

AirCode One


In my case, I had to add the two dlls as reference to my project.

enter image description here

like image 3
nobody Avatar answered Nov 06 '22 03:11

nobody