Telerik blogs

As some of us have found the latest installment of MS AJAX is not backwards compatible. Shortly after ScottGu’s official statement our QA team reported that none of our controls worked with MS AJAX Beta 1. That is really bad news if you happen to claim to be the first ASP.NET component vendor with official ATLAS support. This called for a desperate debugging session which happens to be what I and Hristo Deshev like the most :). So I downloaded and installed the latest version (kudos to Microsoft for the painless install). I created an “Ajax enabled web site” and wired up r.a.d.input. Indeed our control died after being updated by the UpdatePanel – the JavaScript object representing it was never initialized. I used FireBug to see that the init script was not emitted after the update. We used Page.ClientScript.RegisterStartupScript to emit that init script and it used to work like a charm in the April ATLAS CTP. I felt that I lack some ATLAS/AJAX knowledge and summoned Hristo Deshev. It turned out to be a very good idea (pair programming really works). First we tried to find the answer in google – no luck (actually there was a comment by ScottGu but we found it later). Then we used every .NET developer’s swiss army knife – Reflector. That sacred tool showed us that we should start using Microsoft.Web.UI.ScriptManager.Register* instead of Page.ClientScript.Register*. We did a quick test and r.a.d.input was back in the game. The real challenge is calling those methods without dragging in a reference to MS AJAX's assemblies and without forcing each and every one of our customers to do exactly that. We don't want to have a separate build of our suite and confuse our customers either. We could have added a set of build flags and could have branched the entire suite, so that it has two separate versions: with and without MS AJAX support. That would have been really confusing and error prone to many people. We decided to use reflection instead (don’t worry, it works in Medium Trust :)). For example here is how to get the current script manager (still no reflection here):

private object GetScriptManager()
   foreach (DictionaryEntry entry in Page.Items)
      if (entry.Key.ToString().IndexOf("Microsoft.Web.UI.ScriptManager") >= 0)
           return entry.Value;
   throw new ArgumentException("...");

Then calling the RegisterStartupScript method (as well as a few others) was a piece of cake. We used reflection to call those methods it worked.

Luckily all MS AJAX related code lives in a base class so those changes will be picked up by all controls.

We will do our best to release a new service pack addressing MS AJAX Compatibility issues next Monday. Have in mind that the service pack release will no longer support older versions of ATLAS.

About the Author

Stefan Rahnev

Stefan Rahnev (@StDiR) is Product Manager for Telerik Kendo UI living in Sofia, Bulgaria. He has been working for the company since 2005, when he started out as a regular support officer. His next steps at Telerik took him through the positions of Technical Support Director, co-team leader in one of the ASP.NET AJAX teams and unit manager for UI for ASP.NET AJAX and Kendo UI. Stefan’s main interests are web development, agile processes planning and management, client services and psychology.


Comments are disabled in preview mode.