Ajax Control Toolkit is loading too many script resources

断了今生、忘了曾经 提交于 2019-12-30 03:12:32

问题


I created a new project. I installed Ajax Control Toolkit from NuGet. Then I created a new page aspx with following code:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <ajaxToolkit:ToolkitScriptManager ID="toolkitScriptMaster" runat="server">
        </ajaxToolkit:ToolkitScriptManager>
       hello!!!!

    </div>
    </form>
</body>
</html>

I was dumbfounded when I saw that ajaxtookit created 152 scriptresources files. I am worried because I know that this can affect the loading time of the page.

Is it normal?

What can I do?


回答1:


CodePlex's AjaxControlToolkit release of July 2013 introducing control bundles.

After this by default AjaxControlToolkit loads all scripts. So, to manage what scripts for what controls should be added and grouped you need to add AjaxControlToolkit.config to root of your web application project. Like in the following example:

<ajaxControlToolkit>
  <controlBundles>
    <controlBundle>
      <control name="CalendarExtender" />
      <control name="ComboBox" />
        </controlBundle>
    <controlBundle name="CalendarBundle">
      <control name="CalendarExtender"></control>
    </controlBundle>
  </controlBundles>
</ajaxControlToolkit>

Then you will need to specify which bundels are going to be used on which page (or master page if you have controls which are used on all pages) by adding bundle with specific name to toolkit script manager control:

<ajaxToolkit:ToolkitScriptManager runat="server" CombineScripts="true" 
  ScriptMode="Release" >
  <ControlBundles>
       <ajaxToolkit:ControlBundle Name="Calendar" />
  </ControlBundles>
</ajaxToolkit:ToolkitScriptManager>

Remarks: here you can find example of the config which contains most (maybe all definition of the controls from ajax control toolkit library).



来源:https://stackoverflow.com/questions/19710731/ajax-control-toolkit-is-loading-too-many-script-resources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!