TechEd 2006 : ASP.NET 2.0 & Ajax
I entered this session as triggers were being defined for an UpdatePanel using an UpdateProgress AJAX server control…
Just as a quick aside. The project codenamed “Atlas” was released as Beta in it’s new renamed form. So, the new names and logical seperation is as follows :
- The server-side ‘tags’ (embedded in HTML) that are available within ASP.NET 2.0 are called the ASP.NET 2.0 AJAX Extensions.
(Note that the ‘atlas :’ prefix is no longer in use. The ‘asp:’ prefix is to be used instead .)
- The Atlas Control Toolkit is renamed to the ASP.NET AJAX Control Toolkit
The latest download is of this is available at : ASP.NET AJAX 1.0 Beta 2
There is a host of Ajax controls being developed by the community. These include everything from a collapsable panel to a filtered textbox. These controls are available at the ASP.NET AJAX site.
So, with this much info comes the inevitable question – which method should I use when making an aynchronous ajax call from my web application ? The options are the In-built ASP.NET 2.0 Ajax Extensions or the Microsoft Ajax Library.
Using ASP.NET 2.0 Ajax Extensions
In general , this takes about 5 minutes to apply to an existing web form in your (ASP.NET 2.0) application. If we take the scenario where you have a gridview on your form and you have paging setup.
Each time that you move to another page, your browser will make a round trip to the server to get the data via your web service and your page is rendered to the client browser each time. This causes the browser to ‘blank’ as the round-trip is being performed.
You can by-pass the ‘blank’ effect by implementing an AJAX call for the data that you request.
To do this using ASP.NET 2.0 Ajax Extensions, you will need a scriptmanager, then wrap the datagrid in an updatepanel as illustrated here :
< scriptmanager EnablePartialRendering="True" runat="server" ID="scriptmanager1" /> < asp:UpdatePanel ID="updatePanel1" runat="server"> < contentTemplate"> < asp:gridView...> columns, etc go here < /asp:gridView"> < /contentTemplate"> < /asp:UpdatePanel>
…and that’s it in it’s simplest form. When you next use your grid, any callback to the server will be executed as an ajax callback with partial rendering.
Using ASP.NET 2.0 Ajax Library
Given this, I would recommend using this method to return data that will be displayed on the page in any case (eg. First name, Surname for a Person) – i.e. not a good idea to return full credit card info and primary keys, etc…. Also, in general, I would use the ajax extensions for handling a data control such as a gridview.
I would then use this (i.e. Ajax library) for updating fields on a screen that represents an instance of a class (eg. the Person class) or for any validation that requires a simple db call.
An in-depth look at the Microsoft AJAX Library is available at : http://msdn.microsoft.com/msdnmag/issues/07/01/ExtremeASPNET/default.aspx
(why reinvent the wheel !)
So, in conclusion, ASP.NET and Ajax will enhance your web applications through partial postbacks, direct method calls to your code behind/web service and enrich user experience through the implementation of the ASP.NET AJAX Control Toolkit.