The ASP.NET Ajax Library includes the Ajax Control Toolkit. The Ajax Control Toolkit is a rich set of 40 client controls that includes controls for creating auto-complete textboxes, modal popups, calendars, collapsible panels, and masked edit textboxes. You can use all of the Ajax Control Toolkit controls within an ASP.NET Web Forms application by dragging and dropping the controls from the Visual Studio toolbox. You can use the majority of the controls within an ASP.NET MVC application or even a pure HTML application.
The ASP.NET Ajax Library was designed to work seamlessly with jQuery. All of the ASP.NET Ajax Library controls are exposed as jQuery plug-ins automatically.
Why Use the Microsoft Ajax Library?
Ajax features enable you to build rich Web applications that have many advantages over Web applications that are completely server-based. Ajax-enabled applications offer:
- Complete client side processing for Ajax applications, where the client-script libraries can be included without using server-side technology.
- Familiar UI elements such as progress indicators, tooltips, and pop-up windows.
- Improved efficiency for WebForms based applications, because all or significant parts of a Web page's processing can be performed in the browser.
- Partial-page updates for WebForms based application that refresh only the parts of the Web page that have changed.
- Client integration with ASP.NET application services for forms authentication, roles, and user profiles.
- Auto-generated proxy classes that simplify calling Web service methods from client script.
- A framework that lets you customize server controls to include client capabilities.
- Support for the most popular and generally used browsers, which includes Microsoft Internet Explorer, Mozilla Firefox, and Apple Safari.
Architecture of Microsoft Ajax
Features The architecture of a Microsoft Ajax Web application consists of either a client only solution or a client and server solution. A client only solution consists of using the Microsoft Ajax Library without using ASP.NET server controls. For instance, an .html page could include script tags that include the Microsoft Ajax Library script files. The Microsoft Ajax Library allows the Ajax applications to perform all processing on the client. A client and server solution consists of using both the Microsoft Ajax Library and ASP.NET server controls. Microsoft Ajax Library The Microsoft Ajax Library contains script files that encompass Ajax functionality for creating pure Ajax applications. The Microsoft Ajax Library is released separately from the ASP.NET framework or Visual Studio. You can download the latest version of the Microsoft Ajax Library by visiting the www.ASP.net/ajax website. The Microsoft Ajax Library consists of release and debug versions of the following script resources:
To use the features in a Web page, you must first enable Microsoft Ajax on the page and include the client script libraries that you want to use. This is done either by using script tags or by including a server-side ScriptManager control in the page under which you add one or more ScriptReference controls. You can then include the optional script files for specific functionality:
- MicrosoftAjaxTemplates.js (or MicrosoftAjaxTemplates.debug.js)
- MicrosoftAjaxAdoNet.js (or MicrosoftAjaxAdoNet.debug.js)
- MicrosoftAjaxDataContext.js (or MicrosoftAjaxDataContext.debug.js)
You can reference the Microsoft Ajax Library that is included either directly in the project from script files or from the Microsoft Ajax Content Delivery Network (CDN).
The following example shows how to reference the static Microsoft Ajax scripts libraries using script tags when you have downloaded the separate Microsoft Ajax client script libraries and included them in the scripts directory within the project:
The following example shows how to reference Microsoft Ajax client script libraries using the Microsoft Ajax Content Delivery Network (CDN):
When using Visual Studio 2010, the following example illustrates how to use the ScriptManager control to include the Microsoft Ajax client script libraries automatically using the Microsoft Ajax Content Delivery Network (CDN):
<asp:ScriptManager ID="ScriptManager1" EnableCdn="true" runat="server">
When using either Visual Studio 2008 or Visual Studio 2010, the following example shows how to reference the static scripts using the ScriptManager control. In this example, the client script libraries have been downloaded and included in the scripts directory within a project:
<asp:ScriptManager ID="sm" runat="server">
<asp:ScriptReference Name="MicrosoftAjax.js" Path="~/scripts/MicrosoftAjax.js" />
<asp:ScriptReference ScriptMode="Inherit" Path="~/scripts/MicrosoftAjaxTemplates.js" />
<asp:ScriptReference ScriptMode="Inherit" Path="~/scripts/MicrosoftAjaxAdoNet.js" />
<asp:ScriptReference ScriptMode="Inherit" Path="~/scripts/MicrosoftAjaxDataContext.js" />
The MicrosoftAjaxTemplates.js file includes the template-rendering engine and template related classes. The MicrosoftAjaxAdoNet.js file includes classes that are specific to ADO.NET data services, such as the AdoNetServiceProxy class. The MicrosoftAjaxDataContext.js file includes facilities for read-write scenarios. Therefore, to use all features of the Microsoft Ajax Library, you would need to include all four script files.
In Microsoft Ajax, the default behavior for the ScriptManager control is to include the complete Microsoft Ajax Library. However, the ScriptManager control supports a MicrosoftAjaxMode property that lets you choose a subset of the framework by using only portions of the library in the form of split script files. The MicrosoftAjaxMode property can have one of the following values:
- Enabled — All Microsoft AJAX scripts are included (legacy behavior). This is the default value of the property.
- Explicit — Each split script file must be added explicitly; it is up to you to make sure that you include all scripts that have dependencies on one another.
- Disabled — All Microsoft Ajax script features are disabled and the ScriptManager control does not reference any scripts automatically.
For more information about split script files, see Reducing the Download Size of the Microsoft AJAX Library.