Microsoft Ajax Client Templates and declarative jQuery

Apparently Brian likes our declarative syntax. And jQuery. And he did something quite fun with them, something we had clearly not anticipated: using Microsoft Ajax’s new declarative syntax to call jQuery plug-ins instead of Microsoft Ajax behaviors as was the original intent.

<input type="text" maxlength="20" size="40" 
   wajbar:submit=”{{ $(self).next(’input:submit’) }}/> 

The way he made that possible is by adding a registration step to make the plug-in accessible through sys:attach. This registration API actually creates a wrapper behavior for the plug-in that gets Microsoft Ajax to believe the plug-in is a regular behavior. The actual plug-in gets called during initialization of the wrapper behavior, using the behavior itself as the options for the plug-in. This works because the declarative engine in Microsoft Ajax will just set plain expando fields for namespaced attributes such as “wajbar:submit” that don’t correspond to a property. Clever.

This is quite interesting and opens up a number of possibilities, such as enabling our declarative syntax to instantiate components from any framework (without the hack of wrapping them in a Microsoft Ajax behavior) if we open up the right extensibility points. This is definitely something I’ll investigate.

What do you think?

Brian’s post:


  • What happens when your designer runs those expando attributes through Dreamweaver or who-knows-what on their Mac? I understand that they are technically unobtrusive in theory, but I don't think they'd work as well as the standard jQuery wireups in practice.

    What he did is neat though, nevertheless.

  • "What do you think?"


  • Yes please, allowing adding jQuery plugins declaratively seems a must. I can imagine it would become a common Wish List item on the ASP.NET forums if this isn't added. Especially as jQuery UI and Layout scripts gain momentum. And would really justify all the positive press around using jQuery.

  • In the next version of ASP.NET AJAX, can you please provide hosted support for the libraries like Google does with JQuery. These ASP.NET AJAX are large and slow. Would be great if they were hosted on Microsoft's servers.


  • @James: yes, I'm working on that. But I'd be interested in knowing where that perception that our libraries are "large and slow" comes from. MicrosoftAjax.js is 22kB on the wire, and the framework is optimized for fast loading. Can you send me mail at bleroy at microsoft so we can chat?

Comments have been disabled for this content.