We have recently completed converting our suite of user interface controls from the latest Community Technology Preview "Atlas" build to ASP.NET AJAX Beta 1. The Beta 1 release of ASP.NET AJAX is significant because it closely resembles what is soon going to be released as the official version 1.0 of the product. However, it does introduce some breaking changes from the CTP versions. I'll tell you about our experience, and give my thoughts on the state of Microsoft's new AJAX development framework.
Just to put things in perspective, our product consists of 12 UI controls that encapsulate common user interface elements (menus, trees, grids, etc.) exposing over 60 client-side classes built on top of the AJAX Library type system. For more information, visit the live demos or the client-side API reference.
After getting over the initial hump, we found ASP.NET AJAX Beta 1 to be remarkably well functioning and stable. Virtually every issue we ran into while converting our Web.UI library and samples to ASP.NET AJAX Beta 1 had to do with our own lack of understanding of how a particular feature works.
Judging by what is being said about ASP.NET AJAX Beta 1 in some blogs and forums, it appears that other people are in a similar situation. Unfortunately, some of them are concluding (incorrectly, I think) that the product itself is buggy. My impression is that Beta 1 is a significant step forward from the CTP versions, and that it is starting to feel like a production-quality release.
For clarity, I will talk separately about converting the core Web.UI library and the live samples application. Most people who have written applications based on a CTP version of "Atlas" will only need to deal with the latter.
Converting the Core Web.UI Library
We addressed the following changes while converting from CTP "Atlas" bits to ASP.NET AJAX Beta 1:
1. Class definitions through prototypes instead of closures. One of the biggest changes in Beta 1 is that prototypes are now being used to define JavaScript classes (more info on Bertrand Le Roy's excellent blog: part 1, part 2). We were actually already using prototype-based class definitions with CTP builds of "Atlas", so no changes were necessary here. So far so good!
2. The new model for client-side events. The old syntax for assigning events on the client was:
object.eventName.add(eventHandler);
The new syntax is:
object.add_eventName(eventHandler);
object.remove_eventName(eventHandler);
For example:
TreeView1.add_nodeSelect(TreeView1_onNodeSelect);
So, instead of having event objects with add/remove methods, we now have add_eventName and remove_eventName methods on the main object directly. Another related Beta 1 addition is the "events" collection on the Sys.Component base class.
We went ahead and applied these changes across the board.
3. The exclusion of type descriptors from the core product. Type descriptors provide the ability to discover type characteristics of a client-side object at runtime. You can use type descriptors to get the list of properties, methods, and events of an object, along with other applicable meta data. To support this functionality, an AJAX Library class needs to implement the Sys.ITypeDescriptorProvider interface. We had this implemented for all of our client side classes.
Since type descriptors were primarily designed to support xml-script, and Microsoft decided not to make xml-script a part of the core v1.0 product (it is still available in the "value add" portion), type descriptors were also moved to the "value add" bucket.
This was probably the biggest disappointment for us when it comes to Beta 1 changes. We found type descriptors to be universally useful, and - even though they were not originally designed to provide reflection - they still give the ability to discover the structure of an object at runtime, which enables some really elegant generic code.
Since our decision was not to make any required dependencies on "value add" functionality, we ended up implementing our own rudimentary reflection for all Web.UI client-side classes. Of course, if a customer of ours does include the "value add" portion of ASP.NET AJAX in their app, they will get support for type descriptors as expected.
4. Support for the new and improved UpdatePanel control. When we first tried the Beta 1 build with Web.UI, none of our controls worked with the new version of the UpdatePanel control. This was pretty depressing for a few minutes, until we remembered what was said at the Atlas Strategic Design Review lab we attended back in August. Client scripts now have to be registered through the ASP.NET AJAX ScriptManager object (as opposed to the ASP.NET Page object).
More info on this change was posted by the developer of the UpdatePanel control Eilon Lipton here. I really like the new version of the UpdatePanel control. I will try to blog about that separately soon.
Converting the Live Samples Application
In comparison to the work described above, converting the live samples application was an easy and routine exercise. My guess is that most developers who have built applications based on CTP bits of "Atlas" should be able to follow similar steps and get to the finish line fairly quickly.
Here is what we did:
1. Removed the old Microsoft.Web.Atlas.dll project reference, and added a reference to the new Microsoft.Web.Extensions.dll, which is now installed in the GAC;
2. Added a reference to the new ComponentArt.Web.UI.dll, build 2006.2.1470.3;
3. Changed the <atlas: tag prefix to <asp:;
4. Applied the following API changes to all UpdatePanel instances:
a. Changed the Mode property to UpdateMode;
b. Changed all EventTrigger entries under the Triggers section to AsyncPostBackTrigger.
At this point we were able to compile the app.
5. Then we changed all $ JavaScript calls to get$. In order to play nicely and not cause collisions with other frameworks, Microsoft has decided to rename the $ function to $get. This function essentially evaluates to document.getElementById, making it easier to get instances of DOM objects in your code.
That was it!
The entire conversion effort took about 4 days, which really isn't bad considering the size of our product.
Without any doubt, there is a lot of room for improvement of documentation, samples and tutorials for the upcoming ASP.NET AJAX releases. Maybe more than the core framework itself. The really good news is that all of the big changes are already included in the product, so it's a great time to start developing with ASP.NET AJAX!
I would be curious to hear about your experience with ASP.NET AJAX Beta 1, especially if you are using ComponentArt Web.UI.