Core Functionality C# Help

The core functionality of ASP.NET AJAX is divided into two parts, the AJAX Extensions and the AJAX Ubrary

AJAX Extensions

ASP.NET AJAX functionality is contained in two assemblies that are installed in the GAC:

  • System.web.Extensions. dll – This assembly contains the ASP.NET AJAX functionality, including the AJAX Extensions and the AJAX Library JavaScript files, which are available through the ScriptManager component (which is described
  • System.wep.Extensions. Design. dll- This assembly contains ASP.NET Designer components for the AJAX Extensions server controls. This is used by the ASP.NET Designer in Visual Studio or Visual Web developer

Much of the AJAX Extensions component of ASP.NET AJAX is concerned with enabling partial-page
postbacks and J50N serialization for Web services. This includes various HTTP handler components and extensions to the existing ASP.NET framework. AIl of this functionality can be configured through the Web.config Ide for a Web site. There are also classes and attributes that you can use for  additional configuration. However, most of this configuration is transparent, and you will rarely need to change what is supplied in, for example, the ASP.NET Web Site template .

Your main interaction with AJAX Extensions will be using server controls to add Ajax functionality to yout Web applications. There are several of these, which you can use to enhance your applications in
various ways. The following table shows a selection of the server-side components. You see these components in action later .

Control          Description

ScriptManager: This control is central to ASP.NET AJAX functionality and is required on every page that uses partial-page postbacks. Its main purpose is to manage client-side references to the AJAX Library JavaScript IDes, which are served from the ASP.NET AJAX assembly. The AJAX Library is used extensively by. the AJAX Extensions server controls, which all generate their own client-side code.

ThW control is also responsible for the configuration of Web services that you intend to access from client-side code. By supplying Web service information to the ScriptManager control, you can generate client-side and server-side classes to manage asynchronous communication with Web services transparently.

You can also use the ScriptManager control to maintain references to your own JavaScript files.

UpdatePanel: The UpdatePanel control is an extremely useful one and is perhaps the ASP.NET AJAX control that you will use most often. This control acts like a standard ASP.NET placeholder and can contain any other controls. More important, it also marks a section of a page as a region that can be updated independently of the rest of the page, in a partial-page postback.

Any controls contained by an UpdatePanel control that cause a postback (a Button control, for example) will not cause full-page postbacks. Instead, they cause partial-page postbacks that will update only the contents of the UpdatePanel.

In many situations, this control is all you need to implement Ajax functionality. For example, you can place a GridView control in an UpdatePanel control, and any pagination, sorting, and other postback-functionality of the control will take place in a ‘partial-page postback.

UpdateProgress: This control enables you to provide feedback to users when a partial page postback is in progress. You can supply a template for this control that will be displayed when an UpdatePanel is updating. For example, you could use a floating <di v» control to display a message such as “Updating … ” so that the user is aware that the application is busy. Note that partial-page postbacks do not interfere with the rest of a Web page, which will remain responsive.

Timer: The ASP.NETAJAXTimer control is a useful way to cause an UpdatePanel to update periodically. Youcan configure this control to trigger postbacks at regular intervals. If this control is.contained in an UpdatePanel control, then the UpdatePanel will be updated every time the Timer control is triggered. This control also has an associated event so that you can carry out periodic server-side processing.

AsyncPostBackTrigger: You can use this control to trigger UpdatePanel updates from controls that aren’t contained in the UpdatePanel. For example, you can enable a drop-down list elsewhere on a Web page to cause an UpdatePanel containing a GridView control to update.

The AJAXExtensions also include the ExtenderControl abstract base class for extending existing ASP. NET server controls. This is used, for example, by various classes in the ASP.NETAJAXControl Toolkit, as you will see shortly.

AJAX Library

The AJAXLibrary consists of JavaScript files that are used by client-side code in ASP.NETAJAX-enabled Web applications. There is a lot of functionality included in these JavaScript files, some of which is general code that enhances the JavaScript language and some of which is specific to Ajax functionality. The AJAX Library contains layers of functionality that are built on top of each other, as shown in the following table.

Layer                     Description

Browser compatibility: The lowest-level code in the AJAXLibrary consists of code that maps various
JavaScript functionality according to the client WEB browser necessary because there are differences in the implementations of JavaScript in different browsers. By providing this layer, JavaScript code mother layers does “not have to worry about browser compatibility, and you can write browser-neutral code that will work in all client environments.

Core services: This layer contains the enhancements to the JavaScript language, in particular OOP functionality. By using the code in this layer can define spaces, ” classes, derived classes, and interfaces using JavaScript script files. This is of pallicular interest to C# developers, because it makes writing JavaScript code much more like writing .NET code with using C# and encourages reusability.

Base class library: The client base class library (BCL)includes many JavaScript classes that provide low-level functionality to classes further down the AJAXLibrary hierarchy. Most of these classes are not intended to be used directly.

Networking: Classes in the networking layer enable client-side code to call server-side code asynchronously. This layer includes the basic framework for making a call to a URLand responding to the result in a callback function. For the most part, this is also functionality that you will not use directly; instead, you will use classes that wrap this functionality. This layer also contains classes for JSON serialization and deserialization. You will find most of the networking classes on the client-side Sys .Net namespace.

User interface: This layer contains classes that abstract user interface elements such as HTML elements and OOM events. You can use the properties and methods of this layer to write language-neutral JavaScript code to manipulate Webpages from the client. User interface classes are contained in the Sys .UI namespace.

Controls: The final layer of the AJAXLibrary contains the highest-level code, which provides Ajax behaviors and server control functionality. This includes dynamically generated code that you can use, for example, to call Webservices from client- side JavaScript code.

You can use the AJAXLibrary to extend and customize the behavior of ASP.NETAJAX-enabled Web applications, but it is important to note that you don’t have to. You can go a long way without using any additional JavaScript in your applications – it becomes a requirement only when you require more advanced functionality. If you do write additional client-side code, however, you will find that it is much easier with the functionality that the AJAALibrary offers.

ASP. NET AJAX Control Toolkit

The AJAXControl Toolkit is a collection of additional server controls, including extender controls, that have been written by the ASP.NETAJAXcommunity. Extender controls are controls that-enable you to add functionality to an existing ASP.NETserver control, typically by associating a client-side behavior with it. For example, one of the extenders in the AJAXControl Toolkit extends the TextBox control by placing “watermark” text in the TextBox, which appears when the user hasn’t yet added any content to the text box. This extender control is implemented in a server control called TextBoxWa termark.

You can use the AJAXControl Toolkit to add quite a lot more functionality to your sites, beyond what is in the core download. These controls are also interesting Simply to browse and will probably give you plenty of.ideas about enhancing your Web applications. However, because the AJAXControl Toolkit is separate from the core download, you should not expect the same level of support for these controls.

Posted on November 2, 2015 in ASP.NET AJAX

Share the Story

Back to Top
Share This