Ajax Control Toolkit 正在加载过多的脚本资源

编程入门 行业动态 更新时间:2024-10-23 20:20:30
本文介绍了Ajax Control Toolkit 正在加载过多的脚本资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个新项目.我从 NuGet 安装了 Ajax Control Toolkit.然后我使用以下代码创建了一个新页面 aspx:

<head runat="服务器"><title></title><身体><form id="form1" runat="server"><div><ajaxToolkit:ToolkitScriptManager ID="toolkitScriptMaster" runat="server"></ajaxToolkit:ToolkitScriptManager>你好!!!!

</表单>

当我看到ajaxtokit创建了152个脚本资源文件时,我傻眼了.我很担心,因为我知道这会影响页面的加载时间.

正常吗?

我能做什么?

解决方案

CodePlex 于 2013 年 7 月发布的 AjaxControlToolkit 介绍控制包.

此后默认情况下 AjaxControlToolkit 加载所有脚本.因此,要管理应该添加和分组哪些控件的脚本,您需要将 AjaxControlToolkit.config 添加到您的 Web 应用程序项目的根目录.就像下面的例子:

<控制包><控制包><控件名称="CalendarExtender"/><控件名称="ComboBox"/></controlBundle><controlBundle 名称="CalendarBundle"><控件名称="CalendarExtender"></control></controlBundle></controlBundles></ajaxControlToolkit>

然后您需要通过将具有特定名称的包添加到工具包脚本管理器控件来指定将在哪个页面上使用哪些包(或母版页,如果您有在所有页面上使用的控件):

<ajaxToolkit:ToolkitScriptManager runat="server" CombineScripts="true"ScriptMode="发布" ><控制包><ajaxToolkit:ControlBundle Name="日历"/></ControlBundles></ajaxToolkit:ToolkitScriptManager>

备注:此处您可以找到配置示例其中包含最多(可能是ajax控件工具包库中控件的所有定义).

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

<html xmlns="www.w3/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?

解决方案

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).

更多推荐

Ajax Control Toolkit 正在加载过多的脚本资源

本文发布于:2023-11-25 02:10:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627894.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正在加载   脚本   资源   Ajax   Control

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!