locked
Is there any way for accessing Application Object in ScriptReference of AjaxControlToolKitScriptManager RRS feed

  • Question

  • User306497674 posted

    Hi,

    I'm trying to add scripts of Telerik to AjaxControlToolKitScriptManager . I want to use an Application Object for Mentioning path to ScriptReference  like

    Path= "<%= Application["JavaScript" %>/Telerik/Core.js"/>  But It is not allowing me to do so . Please help me in fixing this issue.

     <ajaxToolkit:ToolkitScriptManager ID="scriptManager" OnAsyncPostBackError="OnAsyncError" AsyncPostBackTimeout="2000" EnablePageMethods="true" EnablePartialRendering="true" runat="server" CombineScripts="true">
    <asp:ScriptReference Path="~/JavaScript/Telerik/Core.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/Ajax.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/jQuery.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/jQueryPlugins.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadGridScripts.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/GridCellSelection.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/TouchScrollExtender.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/OverlayScript.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/NavigationScripts.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/AnimationScripts.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadComboBoxScripts.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadMenuScripts.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadContextMenuScripts.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadFilterScripts.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadMenuItem.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadAutoCompleteBoxScripts.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/PopUpScripts.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadToolTipScripts.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadToolTipManager.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadInputScript.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadDateInputScript.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadCalendarCommonScript.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadCalendarScript.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadDatePicker.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadPickersPopupDirectionEnumeration.js"/>,
                    <asp:ScriptReference Path="~/JavaScript/Telerik/RadInputManagerScript.js"/>
    </ajaxToolkit:ToolkitScriptManager>





    Thursday, August 14, 2014 9:41 AM

Answers

  • User-417640953 posted

    I'm trying to add scripts of Telerik to AjaxControlToolKitScriptManager . I want to use an Application Object for Mentioning path to ScriptReference  like

    Hi SreeRama87,

    Thank you post the issue to asp.net forum.

    What I understand from you is you want to add the reference javascript file to ToolkitScriptManager dynamically.

    For this issue, I think you add javascript files in the code behind like below.

    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
                <Services> 
                </Services>
    </asp:ToolkitScriptManager>

    code behind:

    protected void Page_Load(object sender, EventArgs e)
            {
                ToolkitScriptManager1.Services.Add(new ServiceReference("//code.jquery.com/jquery-1.10.2.js"));
                ToolkitScriptManager1.Services.Add(new ServiceReference("//code.jquery.com/ui/1.11.1/jquery-ui.js"));
                //........
            }

    Hope this helps, thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 15, 2014 7:14 AM

All replies

  • User-417640953 posted

    I'm trying to add scripts of Telerik to AjaxControlToolKitScriptManager . I want to use an Application Object for Mentioning path to ScriptReference  like

    Hi SreeRama87,

    Thank you post the issue to asp.net forum.

    What I understand from you is you want to add the reference javascript file to ToolkitScriptManager dynamically.

    For this issue, I think you add javascript files in the code behind like below.

    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
                <Services> 
                </Services>
    </asp:ToolkitScriptManager>

    code behind:

    protected void Page_Load(object sender, EventArgs e)
            {
                ToolkitScriptManager1.Services.Add(new ServiceReference("//code.jquery.com/jquery-1.10.2.js"));
                ToolkitScriptManager1.Services.Add(new ServiceReference("//code.jquery.com/ui/1.11.1/jquery-ui.js"));
                //........
            }

    Hope this helps, thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 15, 2014 7:14 AM
  • User306497674 posted

    Thank you Fuxiang Zhang for the reply . My implementation has been changed, I don't want to keep it in code behind .  I'm keeping the referenced files in a bundle on a static server and want to reference to the AjaxControlToolKitScriptManager . It is not working .  Is there any other way out?.  Below is the code  which I'm trying to implement.

       public void IncludeBundleFiles(BundleCollection bundles)
            {
    
        bundles.Add(new ScriptBundle("~/JavaScript/TelerikListMaster").Include(
                    "~/JavaScript/Telerik/Core.js",
                    "~/JavaScript/Telerik/Ajax.js",
                    "~/JavaScript/Telerik/jQuery.js",
                    "~/JavaScript/Telerik/jQueryPlugins.js",
                    "~/JavaScript/Telerik/RadGridScripts.js",
                    "~/JavaScript/Telerik/GridCellSelection.js",
                    "~/JavaScript/Telerik/OverlayScript.js",
                    "~/JavaScript/Telerik/NavigationScripts.js",
                    "~/JavaScript/Telerik/AnimationScripts.js",
                    "~/JavaScript/Telerik/RadComboBoxScripts.js",
                       "~/JavaScript/Telerik/TouchScrollExtender.js",
                    "~/JavaScript/Telerik/RadMenuScripts.js",
                    "~/JavaScript/Telerik/RadContextMenuScripts.js",
                    "~/JavaScript/Telerik/RadFilterScripts.js",
                    "~/JavaScript/Telerik/RadMenuItem.js",
                    "~/JavaScript/Telerik/RadAutoCompleteBoxScripts.js",
                    "~/JavaScript/Telerik/PopUpScripts.js",
                    "~/JavaScript/Telerik/RadToolTipScripts.js",
                    "~/JavaScript/Telerik/RadToolTipManager.js",
                    "~/JavaScript/Telerik/RadInputScript.js",
                    "~/JavaScript/Telerik/RadNumericInputScript.js",
                    "~/JavaScript/Telerik/RadCalendarCommonScript.js",
                    "~/JavaScript/Telerik/RadCalendarScript.js",
                    "~/JavaScript/Telerik/RadDatePicker.js",
                    "~/JavaScript/Telerik/RadPickersPopupDirectionEnumeration.js",
                    "~/JavaScript/Telerik/RadInputManagerScript.js"));
        }
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" CombineScripts="true" ScriptMode="Release">
                    <CompositeScript Path="https://localhost/JavaScript/TelerikListMaster">
                        <Scripts>
                            
                        </Scripts>
                    </CompositeScript>
                </asp:ToolkitScriptManager>




    Wednesday, August 20, 2014 1:47 AM
  • User-417640953 posted

    Hi SreeRama87,

    Thanks for your post.

    My implementation has been changed, I don't want to keep it in code behind . 

    Based on your description, I see you want to add bundling and minification javascript files to web forms.

    How the bundling files cannot used in the ToolkitScriptManager, you can use the Scripts.Render() replace it like below.

    <asp:PlaceHolder runat="server">        
             <%: Scripts.Render("~/bundles/modernizr") %>
             <%: Scripts.Render("~/bundles/jquery") %>
             <%: Scripts.Render("~/bundles/jqueryui") %>
    </asp:PlaceHolder>
    <asp:ScriptManager runat="server">
            <Scripts>
                <%--        
                <asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="jquery.ui.combined" />
                --%>
            </Scripts>
     </asp:ScriptManager>
    

    http://blogs.msdn.com/b/rickandy/archive/2012/08/14/adding-bundling-and-minification-to-web-forms.aspx

    Besides, I suggest you posting new issue to new thread. that will makes our thread more contrapuntal.

    Best Regards,

    Fuxiang

    Wednesday, August 20, 2014 9:29 PM