MS AJAX Beta1 - ClientScript is dead, long live ScriptManager

Posted by: the telerik blogs, on 23 Oct 2006 | View original

As some of us have found the latest installment of MS AJAX is not backwards compatible. Shortly after ScottGus 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 developers 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 (dont 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.

Advertisement
The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.

Similar Posts

  • Ajax.NET Professional 6.6.2.2 with new Converters more
  • Download latest Ajax.NET Professional 6.4.28.1 more
  • Less waiting on AJAX more
  • The AJAX hysteria more
  • Sending Email from a Web Page with ASP.NET 1.1 more

News Categories

.NET | ADO.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Community Server | dasBlog | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD