Question

i want to include latest jquery in my web application. Bydefault jquery 1.7.1 is getting load.

i know following code is responsible for that. but what should i do to load jquery 1.10?

  <asp:ScriptManager runat="server">
        <Scripts>
            <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
            <%--Framework Scripts--%>
            <asp:ScriptReference Name="MsAjaxBundle" />
            <asp:ScriptReference Name="jquery" />
            <asp:ScriptReference Name="bootstrap" />
            <asp:ScriptReference Name="respond" />
            <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
            <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
            <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
            <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
            <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
            <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
            <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
            <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
            <asp:ScriptReference Name="WebFormsBundle" />
            <%--Site Scripts--%>
        </Scripts>
    </asp:ScriptManager>
Was it helpful?

Solution

To do that you have to create your own JS bundle it is usually in Global.asax or App_Start/BundleConfig.cs

in there you have to add something like below this keep changes according to version so might be little different.

ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
    {
        Path = "~/Scripts/jquery-" + str + ".min.js", //your path will be ignored
        DebugPath = "~/Scripts/jquery-" + str + ".js",  //your path will be ignored 
        **CdnPath = "http://code.jquery.com/jquery.min.js",** 
        **CdnDebugPath = "http://code.jquery.com/jquery-latest.js"**, 
        CdnSupportsSecureConnection = true, 
        LoadSuccessExpression = "window.jQuery"
    }); 

and finally enable cdn in for the script manager

<asp:ScriptManager EnableCdn="True" />

might look little complicate but once you set it will work just fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top