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

  • Question

  • User-632680679 posted

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

    after follow

    http://connect.microsoft.com/VisualStudio/feedback/details/735928/in-asp-net-web-application-visual-basic-the-requiredfieldvalidator-doest-work

    When targeting .NET 4.5 we enable Unobtrusive Validation by default. You need to have jQuery in your project and have something like this in Global.asax to register jQuery properly:

                ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition {
                    Path = "~/scripts/jquery-1.4.1.min.js",
                    DebugPath = "~/scripts/jquery-1.4.1.js",
                    CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1.min.js",
                    CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1.js"
                });

    Replacing the version of jQuery with the version you are using. You can also disable this new feature in web.config by removing the following line:

        <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />


    <head id="Head1" runat="server">
    <title></title>
    <link href="css/cupertino/jquery-ui-1.10.3.custom.css" rel="stylesheet">
    <script src="js/jquery-1.9.1.js"></script>
    <script src="js/jquery-ui-1.10.3.custom.js"></script>
    <script src="js/themeswitchertool.js" type="text/javascript"></script>

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

    then search stackoverflow, it said that use nuget to install following

    After install

    Install-Package AspNet.ScriptManager.jQuery.UI.Combined
    Install-Package AspNet.ScriptManager.jQuery

    and change to

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    <title></title>
    <link href="css/cupertino/jquery-ui-1.10.3.custom.css" rel="stylesheet">
    <script src="Scripts/jquery-2.1.0.js"></script>
    <script src="Scripts/jquery-ui-1.10.4.js"></script>
    <script src="js/themeswitchertool.js" type="text/javascript"></script>


    still got error

    Server Error in '/' Application.

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

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: 'jquery' is not a valid script name. The name must end in '.js'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [InvalidOperationException: 'jquery' is not a valid script name. The name must end in '.js'.]
    System.Web.UI.ScriptReference.GetDebugName(String releaseName) +175
    System.Web.UI.ScriptReference.ShouldUseDebugScript(String releaseName, Assembly assembly, Boolean isDebuggingEnabled, Assembly currentAjaxAssembly) +73
    System.Web.UI.ScriptReference.DetermineResourceNameAndAssembly(ScriptManager scriptManager, Boolean isDebuggingEnabled, String& resourceName, Assembly& assembly) +199
    System.Web.UI.ScriptReference.GetUrlFromName(ScriptManager scriptManager, IControl scriptManagerControl, Boolean zip, Boolean useCdnPath) +158
    System.Web.UI.ScriptReference.GetUrlInternal(ScriptManager scriptManager, Boolean zip, Boolean useCdnPath) +943
    System.Web.UI.ScriptReference.GetUrlInternal(ScriptManager scriptManager, Boolean zip) +103
    System.Web.UI.ScriptReference.GetUrl(ScriptManager scriptManager, Boolean zip) +271
    System.Web.UI.ScriptManager.RegisterUniqueScripts(List`1 uniqueScripts) +370
    System.Web.UI.ScriptManager.RegisterScripts() +735
    System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +206
    System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +158
    System.Web.UI.Page.PerformPreRenderComplete() +62
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5409

    Monday, February 10, 2014 4:41 AM

Answers

  • User-825980306 posted

    Did you done ScriptMappings for both jquery and jqueryUI(ScriptManager.ScriptResourceMapping.AddDefinition("jquery.ui.combined",....)


    Refer the below link:
    http://blogs.msdn.com/b/pranav_rastogi/archive/2012/09/21/asp-net-4-5-scriptmanager-improvements-in-webforms.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 10, 2014 11:49 PM

All replies

  • User1508394307 posted

    There was a similar thread http://forums.asp.net/t/1966532.aspx?+jquery+is+not+a+valid+script+name+The+name+must+end+in+js+ 

    Check last post regarding Name in 

    ScriptReference
    Monday, February 10, 2014 9:01 AM
  • User-632680679 posted

    this is not similar post, this is also my post

    could you tell me how to fix?

    i has already added 

     <asp:ScriptReference Name="jquery.ui.combined" />

    however got

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

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajx" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        <link href="css/cupertino/jquery-ui-1.10.3.custom.css" rel="stylesheet">
    	<script src="Scripts/jquery-2.1.0.js"></script>
    	<script src="Scripts/jquery-ui-1.10.4.js"></script>
    	<script src="js/themeswitchertool.js" type="text/javascript"></script>
    	<script type="text/javascript">
    	    $(function () {
    	        $("#tabs").tabs();
    	    });
    	    $(document).ready(function () {
    	        $('#themewidget1').themeswitcher();
    	        $('#themewidget2').themeswitcher();
    	        $('#themewidget3').themeswitcher();
    	        $('#calculate_button').button();
    	        $('#upload_button').button();
    	        $("#themewidget1").hide();
    	        $("#themewidget2").hide();
    	        $("#themewidget3").hide();
    	    });
    
    	</script>
    </head>
    <body>
        <form id="form1" runat="server">
        <ajx:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Name="jquery.ui.combined" />
            </Scripts>
        </ajx:ToolkitScriptManager>
        <script type="text/javascript">
            var prm = Sys.WebForms.PageRequestManager.getInstance();
            prm.add_endRequest(function (s, e) {
                $('#calculate_button').button();
                $('#upload_button').button();
            });
            </script>
        <div>    

    Monday, February 10, 2014 9:34 PM
  • User-825980306 posted

    Did you done ScriptMappings for both jquery and jqueryUI(ScriptManager.ScriptResourceMapping.AddDefinition("jquery.ui.combined",....)


    Refer the below link:
    http://blogs.msdn.com/b/pranav_rastogi/archive/2012/09/21/asp-net-4-5-scriptmanager-improvements-in-webforms.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 10, 2014 11:49 PM
  • User-632680679 posted

    Success, remarkable  blog

    Tuesday, February 11, 2014 12:03 AM