<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Tales from the Evil Empire : jQuery</title><link>http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx</link><description>Tags: jQuery</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Orchard team looking for a new developer</title><link>http://weblogs.asp.net/bleroy/archive/2009/11/23/orchard-team-looking-for-a-new-developer.aspx</link><pubDate>Mon, 23 Nov 2009 19:24:19 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7263678</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=7263678</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2009/11/23/orchard-team-looking-for-a-new-developer.aspx#comments</comments><description>&lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 10px 0px; display: inline; border-top: 0px; border-right: 0px" title="(c) 2005 Bertrand Le Roy" border="0" alt="(c) 2005 Bertrand Le Roy" align="left" src="http://weblogs.asp.net/blogs/bleroy/Dragonfly_5E7683B7.jpg" width="244" height="164" /&gt; My team is looking for a new full-time developer. The project is to build a completely new open-source CMS based on ASP.NET MVC 2. It’s a lot of fun :)&lt;/p&gt;  &lt;p&gt;&lt;a href="https://careers.microsoft.com/JobDetails.aspx?ss=&amp;amp;pg=0&amp;amp;so=&amp;amp;rw=1&amp;amp;jid=9434&amp;amp;jlang=EN"&gt;https://careers.microsoft.com/JobDetails.aspx?ss=&amp;amp;pg=0&amp;amp;so=&amp;amp;rw=1&amp;amp;jid=9434&amp;amp;jlang=EN&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7263678" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/MVC/default.aspx">MVC</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/NHibernate/default.aspx">NHibernate</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/SQL/default.aspx">SQL</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/HTML/default.aspx">HTML</category></item><item><title>Enabling the ASP.NET Ajax script loader for your own scripts</title><link>http://weblogs.asp.net/bleroy/archive/2009/11/23/enabling-the-asp-net-ajax-script-loader-for-your-own-scripts.aspx</link><pubDate>Mon, 23 Nov 2009 15:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7262909</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=7262909</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2009/11/23/enabling-the-asp-net-ajax-script-loader-for-your-own-scripts.aspx#comments</comments><description>&lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 10px 0px; display: inline; border-top: 0px; border-right: 0px" title="(c) 2009 Bertrand Le Roy" border="0" alt="(c) 2009 Bertrand Le Roy" align="left" src="http://weblogs.asp.net/blogs/bleroy/IMG_2351_078C57E8.jpg" width="244" height="164" /&gt; In previous posts, I’ve shown different ways to build a client-side class browser, using the ASP.NET Ajax Libary and jQuery.&lt;/p&gt;  &lt;p&gt;In this post, I’ll focus on a few lines of code from the latest version of that sample. Those few lines of code enable my custom script to benefit from the script loader’s features such as lazy and parallel loading and dependency management.&lt;/p&gt;  &lt;p&gt;An important feature of the script loader is the separation of the script meta-data from the script code itself. The meta-data can include the name of the script, its dependencies, instructions on how to figure out if it’s already loaded, its debug and release URL patterns and a declaration of the lazy components and plug-ins it introduces. The script loader can also handle composite scripts but I won’t cover that in this post.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The &lt;strong&gt;name&lt;/strong&gt; of the script is what will be used to reference it from other scripts and to generate the URL from a pattern. It shouldn’t include the “.js” extension.&lt;/li&gt;    &lt;li&gt;The &lt;strong&gt;dependencies&lt;/strong&gt; and executionDependencies are each a simple array of script names that the script depends on. I’ll explain the difference in a minute.&lt;/li&gt;    &lt;li&gt;The &lt;strong&gt;is loaded&lt;/strong&gt; criterion is a JavaScript expression that returns true if the script is already loaded. This is usually a test on an object that the script file defines. For example, the “templates” script uses !!(Sys.UI &amp;amp;&amp;amp; Sys.UI.Templates). It can assume Sys because it’s defined by start.js. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Debug and release patterns&lt;/strong&gt; are expressions that enable the framework to map script names into debug and release URLs. The ASP.NET Library uses “%/MicrosoftAjax{0}.debug.js” and “%/MicrosoftAjax{0}.js” where % gets replaced with the path where the script loader was downloaded from (this can be CDN or local) and {0} gets replaced with the script name. You can create your own pattern or just provide fixed URLs if you have only one script file. The debug pattern is optional.&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Lazy components and plug-ins&lt;/strong&gt; are helpers that the script loader can create for you and that enable developers to start using your components before they are even loaded and hide the script loading aspects as much as possible. For example, it’s that feature that enables you to write this while still having only start.js loaded:       &lt;pre class="code"&gt;Sys.create.dataView(&lt;span style="color: maroon"&gt;&amp;quot;#myDataView&amp;quot;&lt;/span&gt;, {
    data: myData
});&lt;/pre&gt;
The code that needed to be written for this helper to be created was this: 

    &lt;pre class="code"&gt;behaviors: [&lt;span style="color: maroon"&gt;&amp;quot;Sys.UI.DataView&amp;quot;&lt;/span&gt;]&lt;/pre&gt;
This gets automatically transformed by the script loader into the Sys.create.dataView method, before it even tries to load the actual script that defines Sys.UI.DataView. And if you have jQuery loaded as well, you’ll also get a jQuery plug-in out of it for free, which means that you can do: 

    &lt;pre class="code"&gt;$(&lt;span style="color: maroon"&gt;&amp;quot;.data&amp;quot;&lt;/span&gt;).dataView({data: myData});&lt;/pre&gt;
and instantiate DataView controls over the results of a selector query in one operation. Groovy. Of course, you can do the same with the behaviors and controls that you write in your own scripts, with lots of options to customize names, add parameters, etc. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the case of the class library code, here’s the meta-data declaration code that I had to write:&lt;/p&gt;

&lt;pre class="code"&gt;Sys.loader.defineScript({
  name: &lt;span style="color: maroon"&gt;&amp;quot;classBrowserTree&amp;quot;&lt;/span&gt;,
  releaseUrl: &lt;span style="color: maroon"&gt;&amp;quot;%/TreejQuery.js&amp;quot;&lt;/span&gt;,
  executionDependencies:&lt;br /&gt;    [&lt;span style="color: maroon"&gt;&amp;quot;jQuery&amp;quot;&lt;/span&gt;, &lt;span style="color: maroon"&gt;&amp;quot;Templates&amp;quot;&lt;/span&gt;, &lt;span style="color: maroon"&gt;&amp;quot;ComponentModel&amp;quot;&lt;/span&gt;],
  isLoaded: !!(window.jQuery &amp;amp;&amp;amp;&lt;br /&gt;    window.jQuery.fn.classBrowserTreeView)
});&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;This declares that my script, named “classBrowserTree”, can be found at the URL TreejQuery.js relative to the base URL of the script loader, that it depends on jQuery, Templates and ComponentModel (which themselves have their own dependencies) and that the loader can determine whether it’s already loaded by evaluating the classBrowserTreeView jQuery plug-in.&lt;/p&gt;

&lt;p&gt;Now, loading that script and all its dependencies is as simple as writing this:&lt;/p&gt;

&lt;pre class="code"&gt;Sys.require(Sys.scripts.classBrowserTree);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Notice that as you’re typing this, you actually get full IntelliSense in Visual Studio on the name of the script, which is great for speed and to avoid typos:&lt;img style="border-bottom: 0px; border-left: 0px; margin: 5px auto; display: block; float: none; border-top: 0px; border-right: 0px" title="ScriptLoaderIntelliSense" border="0" alt="ScriptLoaderIntelliSense" src="http://weblogs.asp.net/blogs/bleroy/ScriptLoaderIntelliSense_10B86D5C.png" width="520" height="387" /&gt; &lt;/p&gt;

&lt;p&gt;One of the things that enable the script loader to do its job is a special way to write your script that makes it possible to separate the loading and parsing of the code from its execution.&lt;/p&gt;

&lt;p&gt;Don’t freak out (yet) though as the code you have to introduce is very lightweight and it doesn’t prevent your script from being loaded &lt;em&gt;without&lt;/em&gt; the script loader (with a plain old script tag for example).&lt;/p&gt;

&lt;p&gt;Reversely, a script that doesn’t have the special script loader code can be handled by the script loader but its dependencies must be declared using “dependencies” instead of “executionDependencies” in the meta-data declaration code, which will in effect disable the more advanced features of the script loader such as parallel loading.&lt;/p&gt;

&lt;p&gt;The special code in question is the following:&lt;/p&gt;

&lt;pre class="code"&gt;(&lt;span style="color: blue"&gt;function&lt;/span&gt;() {
  &lt;span style="color: blue"&gt;function &lt;/span&gt;execute() {
    &lt;span style="color: #006400"&gt;// Your code goes here.
&lt;/span&gt;  }
  &lt;span style="color: blue"&gt;if &lt;/span&gt;(window.Sys &amp;amp;&amp;amp; Sys.loader) {
    Sys.loader.registerScript(&lt;br /&gt;      &lt;span style="color: maroon"&gt;&amp;quot;classBrowserTree&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;null&lt;/span&gt;, execute);
  }
  &lt;span style="color: blue"&gt;else &lt;/span&gt;{
    execute();
  }
})();&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;What you see here is a (function() {…})(); wrapper, which is standard practice to isolate code from the global namespace (essentially, it’s a local scope); we also have another named scope in there that we arbitrarily call “execute” (but the name doesn’t matter). This is where you’ll typically put your actual code. Then we have the bootstrapping code that looks for the script loader. If it isn’t found, the code in the execute function is immediately run. If it &lt;em&gt;is&lt;/em&gt; found, the execute function is registered with the script loader but is not immediately executed.&lt;/p&gt;

&lt;p&gt;This wrapper code is what enables the script loader to do its magic. Thanks to this little bit of code, it doesn’t care at all in what order the scripts are being loaded, because it can delay the time when any script actually gets executed until all its dependencies have been successfully loaded.&lt;/p&gt;

&lt;p&gt;This also allows the script loader to load scripts in parallel, even if one depends on another. Normally a script loader would have to download a dependent script first and wait for it to completely load before loading the next script. This ‘serializes’ the loading process and is not good for performance. Modern browsers can download 6 to 8 scripts simultaneously. Separating the loading of a script from its execution allows the loader to take advantage of that, and in most cases, even complex dependency trees can be downloaded completely in parallel, meaning the total time is not the sum of each script, but only the longest one.&lt;/p&gt;

&lt;p&gt;Of course, in order to be wrappable, your code needs to be able to run in a non-global scope. This is good practice anyways and is relatively easy to achieve in most cases, so if it can’t, it may be a good idea to try to determine why and fix it.&lt;/p&gt;

&lt;p&gt;And this is it. I hope I’ve convinced you that the script loader can help you to improve the performance of your applications at a really low cost. It also provides a very worthy client-side equivalent of the server-side ScriptManager that ASP.NET has been providing to developers for years: switching the whole application between debug and release scripts is a breeze, which minimizes the risk of deploying debug scripts in production; dependencies are being handled automatically; script combination is handled.&lt;/p&gt;

&lt;p&gt;(many thanks to &lt;a href="http://weblogs.asp.net/infinitiesloop"&gt;Dave Reed&lt;/a&gt; for helping with this post and of course for implementing an awesome script loader)&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7262909" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Atlas/default.aspx">Atlas</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category></item><item><title>JavaScript class browser: once again with jQuery</title><link>http://weblogs.asp.net/bleroy/archive/2009/10/30/javascript-class-browser-once-again-with-jquery.aspx</link><pubDate>Fri, 30 Oct 2009 17:43:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7243389</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=7243389</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2009/10/30/javascript-class-browser-once-again-with-jquery.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/bleroy/MercuryWeb_1CBF87AD.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 10px 0px; display: inline; border-top: 0px; border-right: 0px" title="(c) 2004 Bertrand Le Roy" border="0" alt="(c) 2004 Bertrand Le Roy" align="left" src="http://weblogs.asp.net/blogs/bleroy/MercuryWeb_thumb_1373269F.jpg" width="184" height="244" /&gt;&lt;/a&gt; I’ve already posted twice about that little class browser application. The first iteration was mostly declarative and can be found here:    &lt;br /&gt;&lt;a title="http://weblogs.asp.net/bleroy/archive/2009/09/14/building-a-class-browser-with-microsoft-ajax-4-0-preview-5.aspx" href="http://weblogs.asp.net/bleroy/archive/2009/09/14/building-a-class-browser-with-microsoft-ajax-4-0-preview-5.aspx"&gt;http://weblogs.asp.net/bleroy/archive/2009/09/14/building-a-class-browser-with-microsoft-ajax-4-0-preview-5.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The second one was entirely imperative and can be found here:   &lt;br /&gt;&lt;a title="http://weblogs.asp.net/bleroy/archive/2009/10/15/entirely-unobtrusive-and-imperative-templates-with-microsoft-ajax-4-preview-6.aspx" href="http://weblogs.asp.net/bleroy/archive/2009/10/15/entirely-unobtrusive-and-imperative-templates-with-microsoft-ajax-4-preview-6.aspx"&gt;http://weblogs.asp.net/bleroy/archive/2009/10/15/entirely-unobtrusive-and-imperative-templates-with-microsoft-ajax-4-preview-6.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This new version builds on top of the code for the imperative version and adds the jQuery dependency in an attempt to make the code leaner and simpler. I invite you to refer to the imperative code (included in the &lt;a href="http://weblogs.asp.net/blogs/bleroy/Samples/ClassBrowserWithjQuery.zip"&gt;archive for this post&lt;/a&gt;) and compare it with the jQuery version, which shows a couple of ways the Microsoft Ajax Library lights up when jQuery is present.&lt;/p&gt;  &lt;p&gt;The first thing I want to do here is convert the plain function I was using to build the browser’s namespace and class tree into a jQuery plug-in:&lt;/p&gt;  &lt;pre class="code"&gt;$.fn.classBrowserTreeView = &lt;span style="color: blue"&gt;function &lt;/span&gt;(options) {
  &lt;span style="color: blue"&gt;var &lt;/span&gt;opts = $.extend({},&lt;br /&gt;    $.fn.classBrowserTreeView.defaults,&lt;br /&gt;    options);
  &lt;span style="color: blue"&gt;return this&lt;/span&gt;;
};&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;That plug-in will have two options: the data to render (which will default to the root namespaces in the Microsoft Ajax Library), and the node template selector (which will default to “#nodeTemplate”):&lt;/p&gt;

&lt;pre class="code"&gt;$.fn.classBrowserTreeView.defaults = {
  data: Type.getRootNamespaces(),
  nodeTemplate: &lt;span style="color: maroon"&gt;&amp;quot;#nodeTemplate&amp;quot;
&lt;/span&gt;};&lt;/pre&gt;

&lt;p&gt;For the moment, as you can see, this plug-in does nothing. We want it to create a DataView control on each of the elements of the current wrapped set. We will do this by calling into the dataView plug-in.&lt;/p&gt;

&lt;p&gt;You may be wondering where this plug-in might come from. Well, that’s the first kind of lighting up that the Microsoft Ajax Library’s script loader (start.js) will do in the presence of jQuery: every control and behavior will get surfaced as a jQuery plug-in, and components will get added as methods on the jQuery object. This is similar to what I had shown a while ago in this post, only much easier:
  &lt;br /&gt;&lt;a title="http://weblogs.asp.net/bleroy/archive/2009/05/04/creating-jquery-plug-ins-from-microsoftajax-components.aspx" href="http://weblogs.asp.net/bleroy/archive/2009/05/04/creating-jquery-plug-ins-from-microsoftajax-components.aspx"&gt;http://weblogs.asp.net/bleroy/archive/2009/05/04/creating-jquery-plug-ins-from-microsoftajax-components.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, we can write this in our own plug-in to create DataView components over the current jQuery wrapped set:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;return this&lt;/span&gt;.dataView({
  data: opts.data,
  itemTemplate: opts.nodeTemplate,
});&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Now we can wire up the itemRendered event of the data view and start enriching the markup that the DataView control rendered for each data item. First, let’s get hold of the nodes in the rendered template and wrap them:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;elt = $(args.nodes);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Then, if the current node is representing a namespace, we want to hook up the expansion button’s click event so that it toggles visibility of the list of children, and we want to “unhide” the button itself (it has a “hidden” class in the default markup):&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(Type.isNamespace(args.dataItem)) {
  elt.find(&lt;span style="color: maroon"&gt;&amp;quot;.toggleButton&amp;quot;&lt;/span&gt;).click(&lt;span style="color: blue"&gt;function &lt;/span&gt;(e) {
    e.preventDefault();
    &lt;span style="color: blue"&gt;return &lt;/span&gt;toggleVisibility(&lt;span style="color: blue"&gt;this&lt;/span&gt;);
  }).removeClass(&lt;span style="color: maroon"&gt;&amp;quot;hidden&amp;quot;&lt;/span&gt;);
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;You can see here that we’re taking advantage of chaining.&lt;/p&gt;

&lt;p&gt;Next thing is to set-up the node link itself. We start by inhibiting the link’s default action. Then we set the text for the link, and finally we set the command that will bubble up to the DataView when the link gets clicked:&lt;/p&gt;

&lt;pre class="code"&gt;elt.find(&lt;span style="color: maroon"&gt;&amp;quot;.treeNode&amp;quot;&lt;/span&gt;).click(&lt;br /&gt;  &lt;span style="color: blue"&gt;function &lt;/span&gt;(e) {&lt;br /&gt;    e.preventDefault();&lt;br /&gt;    &lt;span style="color: blue"&gt;return false&lt;/span&gt;;&lt;br /&gt;  })
  .text(getSimpleName(args.dataItem.getName()))
  .setCommand(&lt;span style="color: maroon"&gt;&amp;quot;select&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Here, I’m using a small plug-in to set the command:&lt;/p&gt;

&lt;pre class="code"&gt;$.fn.setCommand = &lt;span style="color: blue"&gt;function &lt;/span&gt;(options) {
  &lt;span style="color: blue"&gt;var &lt;/span&gt;opts = $.extend({},&lt;br /&gt;    $.fn.setCommand.defaults, options);
  &lt;span style="color: blue"&gt;return &lt;/span&gt;$(&lt;span style="color: blue"&gt;this&lt;/span&gt;).each(&lt;span style="color: blue"&gt;function &lt;/span&gt;() {
    $.setCommand(&lt;span style="color: blue"&gt;this&lt;/span&gt;,&lt;br /&gt;      opts.commandName,&lt;br /&gt;      opts.commandArgument,&lt;br /&gt;      opts.commandTarget);
  });
}
$.fn.setCommand.defaults = {
    commandName: &lt;span style="color: maroon"&gt;&amp;quot;select&amp;quot;&lt;/span&gt;,
    commandArgument: &lt;span style="color: blue"&gt;null&lt;/span&gt;,
    commandTarget: &lt;span style="color: blue"&gt;null
&lt;/span&gt;};&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;I’m using $.setCommand here, which does get created by the framework for me, but I still need to create that small plug-in to make it work on a wrapped set instead of a static method off jQuery. I’ve sent feedback to the team that setCommand and bind should get created as plug-ins by the framework and hopefully it will happen in a future version.&lt;/p&gt;

&lt;p&gt;The last thing we need to do here is to recursively create the child branches of our tree:&lt;/p&gt;

&lt;pre class="code"&gt;elt.find(&lt;span style="color: maroon"&gt;&amp;quot;ul&amp;quot;&lt;/span&gt;).classBrowserTreeView({
    data: getChildren(args.dataItem)
});&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;This just finds the child UL element of the current branch and calls our plug-in on the results with the children namespaces and classes as the data.&lt;/p&gt;

&lt;p&gt;And this is it for the tree, we can now create it with this simple call:&lt;/p&gt;

&lt;pre class="code"&gt;$(&lt;span style="color: maroon"&gt;&amp;quot;#tree&amp;quot;&lt;/span&gt;).classBrowserTreeView();&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;The details view rendering will only differ in minor ways from the code we had in our previous imperative version. The only differences is the use of jQuery to traverse and manipulate the DOM instead of the mix of native DOM APIs and Sys.get that we were using before. For example,&lt;/p&gt;

&lt;pre class="code"&gt;args.get(&lt;span style="color: maroon"&gt;&amp;quot;li&amp;quot;&lt;/span&gt;).innerHTML =&lt;br /&gt;  args.dataItem.getName ?&lt;br /&gt;    args.dataItem.getName() :&lt;br /&gt;    args.dataItem.name;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;becomes:&lt;/p&gt;

&lt;pre class="code"&gt;$(args.nodes).filter("li").text(&lt;br /&gt;  args.dataItem.getName ?&lt;br /&gt;    args.dataItem.getName() :&lt;br /&gt;    args.dataItem.name);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Notice how jQuery’s text method makes things a little more secure than the innerHTML we had used before.&lt;/p&gt;

&lt;p&gt;Updating the details view with the data for the item selected in the tree is done by handling the select command of the tree from the following function:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;onCommand(sender, args) {
  &lt;span style="color: blue"&gt;if &lt;/span&gt;(args.get_commandName() === &lt;span style="color: maroon"&gt;&amp;quot;select&amp;quot;&lt;/span&gt;) {
    &lt;span style="color: blue"&gt;var &lt;/span&gt;dataItem = sender.findContext(&lt;br /&gt;      args.get_commandSource()).dataItem;
    &lt;span style="color: blue"&gt;var &lt;/span&gt;isClass = Type.isClass(dataItem) &amp;amp;&amp;amp;&lt;br /&gt;                 !Type.isNamespace(dataItem);
    &lt;span style="color: blue"&gt;var &lt;/span&gt;childData =&lt;br /&gt;      (isClass ? getMembers : getChildren)(dataItem);
    &lt;span style="color: blue"&gt;var &lt;/span&gt;detailsChild =&lt;br /&gt;      Sys.Application.findComponent(&lt;span style="color: maroon"&gt;&amp;quot;detailsChild&amp;quot;&lt;/span&gt;);
    detailsChild.onItemRendering =&lt;br /&gt;      isClass ?&lt;br /&gt;        onClassMemberRendering :&lt;br /&gt;        onNamespaceChildRendering;
    detailsChild.onItemRendered =&lt;br /&gt;      onDetailsChildRendered;
    detailsChild.set_data(childData);
    $(&lt;span style="color: maroon"&gt;&amp;quot;#detailsTitle&amp;quot;&lt;/span&gt;).text(dataItem.getName());
    $(&lt;span style="color: maroon"&gt;&amp;quot;.namespace&amp;quot;&lt;/span&gt;).css(&lt;br /&gt;      &lt;span style="color: maroon"&gt;&amp;quot;display&amp;quot;&lt;/span&gt;,&lt;br /&gt;      isClass ? &lt;span style="color: maroon"&gt;&amp;quot;none&amp;quot; &lt;/span&gt;: &lt;span style="color: maroon"&gt;&amp;quot;block&amp;quot;&lt;/span&gt;);
    $(&lt;span style="color: maroon"&gt;&amp;quot;.class&amp;quot;&lt;/span&gt;).css(&lt;br /&gt;      &lt;span style="color: maroon"&gt;&amp;quot;display&amp;quot;&lt;/span&gt;,&lt;br /&gt;      isClass ? &lt;span style="color: maroon"&gt;&amp;quot;block&amp;quot; &lt;/span&gt;: &lt;span style="color: maroon"&gt;&amp;quot;none&amp;quot;&lt;/span&gt;);
    $(&lt;span style="color: maroon"&gt;&amp;quot;#details&amp;quot;&lt;/span&gt;).css(&lt;span style="color: maroon"&gt;&amp;quot;display&amp;quot;&lt;/span&gt;, &lt;span style="color: maroon"&gt;&amp;quot;block&amp;quot;&lt;/span&gt;);
  }
}&lt;/pre&gt;

&lt;p&gt;Not much change here from the previous version, again, except for the use of jQuery and some chaining.&lt;/p&gt;

&lt;p&gt;And that is pretty much it. I’ve made other changes in the script to make use of the new script loader in the Microsoft Ajax Library but that will be the subject of a future post.&lt;/p&gt;

&lt;p&gt;Hopefully, this has shown you how the Microsoft Ajax Library can light up with jQuery. The automatic creation of plug-ins feels very much like native jQuery plug-ins and brings all the power of client templates to jQuery. Once we have bind and setCommand plug-ins as well, the Microsoft Ajax Library may become a very useful tool to jQuery programmers just as much as jQuery itself is a very useful tool to Microsoft Ajax programmers.&lt;/p&gt;

&lt;p&gt;The code can be found here:
  &lt;br /&gt;&lt;a title="http://weblogs.asp.net/blogs/bleroy/Samples/ClassBrowserWithjQueryUpdated.zip" href="http://weblogs.asp.net/blogs/bleroy/Samples/ClassBrowserWithjQueryUpdated.zip"&gt;http://weblogs.asp.net/blogs/bleroy/Samples/ClassBrowserWithjQueryUpdated.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; fixed a problem in Firefox &amp; Chrome.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7243389" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Atlas/default.aspx">Atlas</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/HTML/default.aspx">HTML</category></item><item><title>Entirely unobtrusive and imperative templates with Microsoft Ajax Library Preview 6</title><link>http://weblogs.asp.net/bleroy/archive/2009/10/15/entirely-unobtrusive-and-imperative-templates-with-microsoft-ajax-4-preview-6.aspx</link><pubDate>Thu, 15 Oct 2009 09:12:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7230434</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=7230434</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2009/10/15/entirely-unobtrusive-and-imperative-templates-with-microsoft-ajax-4-preview-6.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/bleroy/IMG_2305_0DB1EDD9.jpg"&gt;&lt;img style="border-right-width: 0px; margin: 0px 0px 10px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="(c) 2009 Bertrand Le Roy" border="0" alt="(c) 2009 Bertrand Le Roy" align="right" src="http://weblogs.asp.net/blogs/bleroy/IMG_2305_thumb_138C9172.jpg" width="244" height="164" /&gt;&lt;/a&gt; Today is the release of the sixth preview of Microsoft Ajax Library. Don’t get fooled by the somewhat silly and long name: this is a major release in many ways. The scripts have been majorly refactored since preview 5. Check out the other posts out there (links at the bottom of this post) to see just some of the many new features that are in there. Some of my favorite are all the small improvements that have been made to make imperative instantiation of components and templated contents easier than ever. Many of you have told us that you preferred to do things imperatively and this release makes it a lot better.&lt;/p&gt;  &lt;p&gt;When Preview 5 came out, I built a simple class browser using the declarative syntax. The class browser shows the hierarchy of namespaces and classes in a tree view on the left side of the page, and the details of whatever’s selected in the tree on the right side of the page:&lt;a href="http://weblogs.asp.net/blogs/bleroy/ClassBrowser2_36D98617.png"&gt;&lt;img style="border-right-width: 0px; margin: 5px auto; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The JavaScript class browser" border="0" alt="The JavaScript class browser" src="http://weblogs.asp.net/blogs/bleroy/ClassBrowser2_thumb_23B8596B.png" width="504" height="187" /&gt;&lt;/a&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2009/09/14/building-a-class-browser-with-microsoft-ajax-4-0-preview-5.aspx"&gt;http://weblogs.asp.net/bleroy/archive/2009/09/14/building-a-class-browser-with-microsoft-ajax-4-0-preview-5.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It still works (and an updated version is attached to this post), but I thought I would demonstrate how you can take that same sample and re-implement it in a completely imperative way. Of course, you never have to go all the way one way or another, and it’s always possible for example to use the nice declarative syntax for bindings but instantiate your components imperatively if you choose to do so. In this post, I’m deliberately going imperative all the way. Just keep in mind this is rather extreme.&lt;/p&gt;  &lt;p&gt;The first thing to notice in the new version is that the markup is perfectly clean and contains no weird extension, namespace or custom binding syntax whatsoever. It’s 100% pure HTML 5. Here is for example the complete markup for the tree view on that page:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ul &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;tree&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;tree&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;ul&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;

&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ul &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;nodeTemplate&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;sys-template&amp;quot;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;li&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;a &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;toggleButton&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;href&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;#&amp;quot;&amp;gt;&lt;/span&gt;+&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;a&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;a &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;treeNode&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;href&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;#&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;a&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;ul&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;ul&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;li&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;ul&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;The script that builds the dynamic contents is bootstrapped by the following code:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/javascript&amp;quot;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: red"&gt;src&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Scripts/start.js&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: maroon"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/javascript&amp;quot;&amp;gt;
&lt;/span&gt;Sys.loadScripts([&amp;quot;Scr&lt;span style="color: maroon"&gt;ipts/Tree.js&amp;quot;], f&lt;/span&gt;unc&lt;span style="color: blue"&gt;tion() {
  &lt;/span&gt;Sys.require([Sys.components.dataView], function&lt;span style="color: blue"&gt;() {
    &lt;/span&gt;createTreeView(&amp;quot;#tree&amp;quot;,&lt;br /&gt;                   Typ&lt;span style="color: maroon"&gt;e.getRo&lt;/span&gt;otNamespaces(),&lt;br /&gt;                   &amp;quot;#nodeTempla&lt;span style="color: maroon"&gt;te&amp;quot;);
    &lt;/span&gt;Sys.create.dataView(&amp;quot;#detailsChild&amp;quot;, &lt;span style="color: maroon"&gt;{
      &lt;/span&gt;itemRendered: onDetailsChildRendered
    });
  });
});
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;We’re making use of the new script loader here: we first include the bootstrapper file, start.js, and then we declare that we need one custom script, “tree.js” and everything necessary to instantiate a DataView. The script loader will figure out on its own the set of scripts it needs to download for that. Once those scripts have been downloaded, we call createTreeView, which is custom code that we’ll look at in a moment that creates nested DataView controls over the markup. We also create a second DataView to display the details of what’s selected in the&amp;#160; tree.&lt;/p&gt;

&lt;p&gt;Notice that we set some properties to a selector string here (for example “#nodeTemplate”). This is actually a breaking change from the previous preview, which only understood id strings. Microsoft Ajax does not include a full selector engine but it does understand the most basic of selectors (.class, tagName and #id). But where it gets really interesting is that if you had included jQuery on the page, the framework would detect it and enable you to use full selectors everywhere. Isn’t that sweet?&lt;/p&gt;

&lt;p&gt;So how does the imperative approach compare with the declarative one? Well, for instantiating components, you already have an example above, where we use Sys.create.dataView. But what about wiring up events, setting text contents and attribute values, instantiating components over the markup inside the template?&lt;/p&gt;

&lt;p&gt;All those are done by post-processing the template instances after they’ve been instantiated, by handling the itemRendered event:&lt;/p&gt;

&lt;pre class="code"&gt;itemRendered: &lt;span style="color: blue"&gt;function&lt;/span&gt;(sender, args) {
  &lt;span style="color: #006400"&gt;// do magic
&lt;/span&gt;}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Wiring up events is as simple as getting a reference to an element and calling addHandler:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;toggleButton = args.get(&lt;span style="color: maroon"&gt;&amp;quot;.toggleButton&amp;quot;&lt;/span&gt;);
Sys.UI.DomEvent.addHandler(toggleButton, &lt;span style="color: maroon"&gt;&amp;quot;click&amp;quot;&lt;/span&gt;,&lt;br /&gt;  &lt;span style="color: blue"&gt;function&lt;/span&gt;(e) {
    toggleVisibility(&lt;span style="color: blue"&gt;this&lt;/span&gt;);
  }, &lt;span style="color: blue"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;The args.get function, which you will use a lot, takes a selector and returns the first element that matches it &lt;em&gt;inside the template&lt;/em&gt;. Here, we are looking for an element with class “toggleButton”, but a local id would work just as well.&lt;/p&gt;

&lt;p&gt;To set text contents and attribute values is trivial once you know how to get references to elements from local selectors (remember, jQuery also works here transparently or even explicitly when and if you need it).&lt;/p&gt;

&lt;p&gt;Finally, instantiating components is also quite easy. For example, here is the code that creates an inner DataView for the child nodes of a node in the tree, recursively:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;childView = args.get(&lt;span style="color: maroon"&gt;&amp;quot;ul&amp;quot;&lt;/span&gt;);
createTreeView(childView,&lt;br /&gt;               getChildren(args.dataItem),&lt;br /&gt;               nodeTemplate);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;The args.get funtion is used once more to get a reference to the first UL element within the template, and it is then easy to do a recursive call into our tree creation function and build the new branch of the tree.&lt;/p&gt;

&lt;p&gt;The command bubbling feature that makes it so easy to wire up custom commands into a template is still usable in imperative code:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;treeNode = args.get(&lt;span style="color: maroon"&gt;&amp;quot;.treeNode&amp;quot;&lt;/span&gt;);
Sys.setCommand(treeNode, &lt;span style="color: maroon"&gt;&amp;quot;select&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Finally, there is one feature that I’m not using in that sample, but that’s immensely useful, and I’m talking of course of live bindings. Those work too, all you have to do is call the Sys.bind function and give it the target object, the name of the target property to bind, the source object and the source property name.&lt;/p&gt;

&lt;p&gt;To render the details view, I decided to not use a single item DataView like I did with the declarative version: since I’m going to use imperative code instead of declarative bindings, it is just as easy to directly manipulate the DOM that already exists, and do some hiding and showing of elements:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;onCommand(sender, args) {
  &lt;span style="color: blue"&gt;if &lt;/span&gt;(args.get_commandName() === &lt;span style="color: maroon"&gt;&amp;quot;select&amp;quot;&lt;/span&gt;) {
    &lt;span style="color: blue"&gt;var &lt;/span&gt;dataItem = sender.findContext(&lt;br /&gt;      args.get_commandSource()).dataItem;
    &lt;span style="color: blue"&gt;var &lt;/span&gt;isClass = Type.isClass(dataItem) &amp;amp;&amp;amp;&lt;br /&gt;                 !Type.isNamespace(dataItem);
    &lt;span style="color: blue"&gt;var &lt;/span&gt;childData =&lt;br /&gt;      (isClass ? getMembers : getChildren)(dataItem),
      namespaceElementsDisplay = &lt;br /&gt;        isClass ? &lt;span style="color: maroon"&gt;&amp;quot;none&amp;quot; &lt;/span&gt;: &lt;span style="color: maroon"&gt;&amp;quot;block&amp;quot;&lt;/span&gt;,
      classElementsDisplay =&lt;br /&gt;        isClass ? &lt;span style="color: maroon"&gt;&amp;quot;block&amp;quot; &lt;/span&gt;: &lt;span style="color: maroon"&gt;&amp;quot;none&amp;quot;&lt;/span&gt;,
      detailsChild =&lt;br /&gt;        Sys.Application.findComponent(&lt;span style="color: maroon"&gt;&amp;quot;detailsChild&amp;quot;&lt;/span&gt;);
    detailsChild.onItemRendering =&lt;br /&gt;      isClass ?&lt;br /&gt;        onClassMemberRendering :&lt;br /&gt;        onNamespaceChildRendering;
    detailsChild.set_data(childData);
    Sys.get(&lt;span style="color: maroon"&gt;&amp;quot;#detailsTitle&amp;quot;&lt;/span&gt;).innerHTML =&lt;br /&gt;      dataItem.getName();
    Sys.get(&lt;span style="color: maroon"&gt;&amp;quot;#namespacesColumn&amp;quot;&lt;/span&gt;).style.display =
    Sys.get(&lt;span style="color: maroon"&gt;&amp;quot;#classesColumn&amp;quot;&lt;/span&gt;).style.display =&lt;br /&gt;      namespaceElementsDisplay;
    Sys.get(&lt;span style="color: maroon"&gt;&amp;quot;#propertiesColumn&amp;quot;&lt;/span&gt;).style.display =
    Sys.get(&lt;span style="color: maroon"&gt;&amp;quot;#eventsColumn&amp;quot;&lt;/span&gt;).style.display =
    Sys.get(&lt;span style="color: maroon"&gt;&amp;quot;#methodsColumn&amp;quot;&lt;/span&gt;).style.display =
    Sys.get(&lt;span style="color: maroon"&gt;&amp;quot;#staticMethodsColumn&amp;quot;&lt;/span&gt;).style.display =&lt;br /&gt;      classElementsDisplay;
    Sys.get(&lt;span style="color: maroon"&gt;&amp;quot;#details&amp;quot;&lt;/span&gt;).style.display = &lt;span style="color: maroon"&gt;&amp;quot;block&amp;quot;&lt;/span&gt;;
  }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;We do have a DataView to render the contents of the currently selected object though. The nice trick we used with the declarative version to dynamically switch the target place holder where the template gets rendered is still there, which enables a single DataView control to dispatch the data into two to four separate lists (or however much you want for that matter):&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;onNamespaceChildRendering(args) {
    args.set_itemPlaceholder(
        Type.isClass(args.get_dataItem()) ?
            &lt;span style="color: maroon"&gt;&amp;quot;#classPlaceHolder&amp;quot; &lt;/span&gt;:
            &lt;span style="color: maroon"&gt;&amp;quot;#namespacePlaceHolder&amp;quot;
    &lt;/span&gt;);
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;I think all this is pretty cool and I hope the comparison between the declarative version and the imperative version of this little application gives you a sense of the flexibility that the Microsoft Ajax library now offers, and of how much you can choose your own development style and do pretty much anything with the same ease.&lt;/p&gt;

&lt;p&gt;Download the code for this post here: 
  &lt;br /&gt;&lt;a title="http://weblogs.asp.net/blogs/bleroy/Samples/Preview6ClassBrowser.zip" href="http://weblogs.asp.net/blogs/bleroy/Samples/Preview6ClassBrowser.zip"&gt;http://weblogs.asp.net/blogs/bleroy/Samples/Preview6ClassBrowser.zip&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Microsoft Ajax Library Preview 6 can be downloaded from here:
  &lt;br /&gt;&lt;a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=34488"&gt;http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=34488&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are a few links about this release:
 &lt;br/&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/15/announcing-microsoft-ajax-library-preview-6-and-the-microsoft-ajax-minifier.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2009/10/15/announcing-microsoft-ajax-library-preview-6-and-the-microsoft-ajax-minifier.aspx&lt;/a&gt;
  &lt;br /&gt;&lt;a href="http://channel9.msdn.com/posts/jsenior/Announcing-Microsoft-Ajax-Library-Preview-6/"&gt;http://channel9.msdn.com/posts/jsenior/Announcing-Microsoft-Ajax-Library-Preview-6/&lt;/a&gt;

  &lt;br /&gt;&lt;a href="http://www.jamessenior.com/post/How-the-Script-Loader-in-the-Microsoft-Ajax-Library-will-make-your-life-wonderful.aspx"&gt;http://www.jamessenior.com/post/How-the-Script-Loader-in-the-Microsoft-Ajax-Library-will-make-your-life-wonderful.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7230434" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Atlas/default.aspx">Atlas</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/HTML/default.aspx">HTML</category></item><item><title>querySelectorAll on old IE versions: something that doesn’t work</title><link>http://weblogs.asp.net/bleroy/archive/2009/08/31/queryselectorall-on-old-ie-versions-something-that-doesn-t-work.aspx</link><pubDate>Tue, 01 Sep 2009 01:03:13 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7187174</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=7187174</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2009/08/31/queryselectorall-on-old-ie-versions-something-that-doesn-t-work.aspx#comments</comments><description>&lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 0px 10px 10px; display: inline; border-top: 0px; border-right: 0px" title="(c) Bertrand Le Roy 2005" border="0" alt="(c) Bertrand Le Roy 2005" align="right" src="http://weblogs.asp.net/blogs/bleroy/WallDoor_7CF5A223.jpg" width="224" height="244" /&gt; In today’s post, I’m going to show an interesting technique to solve a problem and then I will tear it to pieces and explain why it is actually useless. I believe that negative results should also be published so that we can save other people from wasting time trying the same thing. So here goes…&lt;/p&gt;  &lt;p&gt;A few days ago, &lt;a href="http://ajaxian.com/archives/creating-a-queryselector-for-ie-that-runs-at-native-speed"&gt;a post on Ajaxian&lt;/a&gt; proposed a new version of a somewhat old technique to implement &lt;a href="http://www.w3.org/TR/2007/WD-selectors-api-20071221/"&gt;querySelectorAll&lt;/a&gt; on old versions of IE, using the browser’s native CSS engine. That sounds like a great idea at first, and the hack is quite clever. The idea is to dynamically add a CSS rule to the document that has the selector that you want to evaluate, and an expression that adds the matched elements to a global array.&lt;/p&gt;  &lt;p&gt;When I read this, it reminded me of a similar approach that I had tried a few years ago. At the time, we were considering implementing our own selector engine (we had not yet decided to integrate jQuery to our Ajax offerings, which in the end made the whole effort moot) so we explored a number of approaches.&lt;/p&gt;  &lt;p&gt;My idea was different in that it doesn’t use expressions at all. It does dynamically create a style rule, but instead of an expression, it just sets a non-existing “foo” style property to the equally arbitrary value of “bar”. It then scans the whole document (using the much decried and IE-specific but very fast document.all) and gets the computed style for each of the elements. We then look for the foo property on the resulting object and check whether it evaluates as “bar”. For each element that matches, we add to an array.&lt;/p&gt;  &lt;p&gt;Here’s the code:&lt;/p&gt;  &lt;pre class="code"&gt;(&lt;span style="color: blue"&gt;function&lt;/span&gt;() {
    &lt;span style="color: blue"&gt;var &lt;/span&gt;style = document.styleSheets[0] ||&lt;br /&gt;                document.createStyleSheet();
    window.select = &lt;span style="color: blue"&gt;function&lt;/span&gt;(selector) {
        style.addRule(selector, &lt;span style="color: #a31515"&gt;&amp;quot;foo:bar&amp;quot;&lt;/span&gt;);
        &lt;span style="color: blue"&gt;var &lt;/span&gt;all = document.all, resultSet = [];
        &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i = 0, l = all.length; i &amp;lt; l; i++) {
            &lt;span style="color: blue"&gt;if &lt;/span&gt;(all[i].currentStyle.foo === &lt;span style="color: #a31515"&gt;&amp;quot;bar&amp;quot;&lt;/span&gt;) {
                resultSet[resultSet.length] = all[i];
            }
        }
        style.removeRule(0);
        &lt;span style="color: blue"&gt;return &lt;/span&gt;resultSet;
    }
})();&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;or, in minimized form:&lt;/p&gt;

&lt;pre class="code"&gt;(&lt;span style="color: blue"&gt;function&lt;/span&gt;(){&lt;span style="color: blue"&gt;var &lt;/span&gt;d=document;&lt;span style="color: blue"&gt;var &lt;/span&gt;a=d.styleSheets[0]||&lt;br /&gt;d.createStyleSheet();window.select=&lt;span style="color: blue"&gt;function&lt;/span&gt;(e){&lt;br /&gt;a.addRule(e,&lt;span style="color: #a31515"&gt;&amp;quot;f:b&amp;quot;&lt;/span&gt;);&lt;span style="color: blue"&gt;var &lt;/span&gt;l=d.all,c=[];&lt;br /&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;b=0,f=l.length;b&amp;lt;f;b++)&lt;span style="color: blue"&gt;if&lt;/span&gt;(l[b].currentStyle.f)&lt;br /&gt;c[c.length]=l[b];a.removeRule(0);&lt;span style="color: blue"&gt;return &lt;/span&gt;c}})()&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;That’s 235 characters, which is not too bad (although not quite #twitcode small).&lt;/p&gt;

&lt;p&gt;The first problem with that approach though is that because it’s using the native CSS selection engine in IE, it has the same limitations and quirks. That means no fancy CSS 3 (or even 2) selectors. It also means any IE bug will surface into the result set.&lt;/p&gt;

&lt;p&gt;In other words, if you want more selectors than that, you will need to parse the selector string and branch off the code to another, more complete engine whenever something not supported is used. It also means that you need to know what is supported and what isn’t. That could be done through some dynamic discovery but doing so, we are getting into much complexity.&lt;/p&gt;

&lt;p&gt;So limited as it is, how does it perform?&lt;/p&gt;

&lt;p&gt;I ran the code in a &lt;a href="http://code.google.com/p/slickspeed/"&gt;SlickSpeed&lt;/a&gt; test (where I removed the selectors that it couldn’t handle) on IE6 and the good news is that despite the document.all scan and the current style computation, it’s more than three times faster than &lt;a href="http://ajaxian.com/archives/creating-a-queryselector-for-ie-that-runs-at-native-speed"&gt;Paul Young’s implementation that got featured on Ajaxian&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But the bad news is that it’s also &lt;strong&gt;six times slower than jQuery:&lt;img style="border-bottom: 0px; border-left: 0px; margin: 5px auto; display: block; float: none; border-top: 0px; border-right: 0px" title="SlickSpeedResults" border="0" alt="SlickSpeedResults" src="http://weblogs.asp.net/blogs/bleroy/SlickSpeedResults_62B538FF.png" width="540" height="484" /&gt; &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’m afraid a hack to use the native CSS selection engine of the browser is always going to be slower than an optimized pure JavaScript implementation (to be clear, I’m not talking about native implementations of querySelectorAll, but about hacks such as this which try to surface the feature on older IE versions that don’t have querySelectorAll). Somewhat counter-intuitive, but true.&lt;/p&gt;

&lt;p&gt;End of story. Just use jQuery. :)&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7187174" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/TwitCode/default.aspx">TwitCode</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category></item><item><title>Survey: Ajax usage among .NET developers</title><link>http://weblogs.asp.net/bleroy/archive/2009/05/22/survey-ajax-usage-among-net-developers.aspx</link><pubDate>Fri, 22 May 2009 19:13:20 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7094884</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>9</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=7094884</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2009/05/22/survey-ajax-usage-among-net-developers.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/bleroy/Copenhagen_36DBEC47.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="(c) Bertrand Le Roy 2003" border="0" alt="(c) Bertrand Le Roy 2003" align="left" src="http://weblogs.asp.net/blogs/bleroy/Copenhagen_thumb_55B26025.jpg" width="204" height="154" /&gt;&lt;/a&gt; If you haven’t already and you are a .NET developer, please take a couple minutes and answer this survey, whether you use Ajax or not. There are a number of Ajax surveys around, but Simone’s is the only one that focuses on .NET developers.&lt;/p&gt;  &lt;p&gt;The survey:   &lt;br /&gt;&lt;a title="http://www.zoomerang.com/Survey/?p=WEB22973CYKW2H" href="http://www.zoomerang.com/Survey/?p=WEB22973CYKW2H"&gt;http://www.zoomerang.com/Survey/?p=WEB22973CYKW2H&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Simone’s post:   &lt;br /&gt;&lt;a href="http://codeclimber.net.nz/archive/2009/05/21/ajax-usage-among-.net-developers-in-2009.aspx"&gt;http://codeclimber.net.nz/archive/2009/05/21/ajax-usage-among-.net-developers-in-2009.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7094884" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Ajax+Control+Toolkit/default.aspx">Ajax Control Toolkit</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category></item><item><title>Creating jQuery plug-ins from MicrosoftAjax components</title><link>http://weblogs.asp.net/bleroy/archive/2009/05/04/creating-jquery-plug-ins-from-microsoftajax-components.aspx</link><pubDate>Tue, 05 May 2009 05:23:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7073206</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>16</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=7073206</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2009/05/04/creating-jquery-plug-ins-from-microsoftajax-components.aspx#comments</comments><description>&lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="(c) Bertrand Le Roy" border="0" alt="(c) Bertrand Le Roy" align="left" src="http://weblogs.asp.net/blogs/bleroy/ConjonctionRetouche_3337CDB8.jpg" width="244" height="156" /&gt; We had an interesting discussion recently on the &lt;a href="http://aspinsiders.com/"&gt;ASP Insiders&lt;/a&gt; mailing list and ended up talking about what cool stuff we could build on top of jQuery. Many interesting things were mentioned and it was a very useful discussion but one suggestion in particular struck my curiosity as it was something I had investigated before and that could be improved on with very little code.&lt;/p&gt;  &lt;p&gt;I had already written &lt;a href="http://weblogs.asp.net/bleroy/archive/2008/09/28/jquery-now-officially-part-of-the-net-developer-s-toolbox.aspx"&gt;a little plugin to enable instantiation of Microsoft Ajax components on the results of a jQuery selector&lt;/a&gt;:&lt;/p&gt;  &lt;pre class="code"&gt;jQuery.fn.create = &lt;span style="color: blue"&gt;function&lt;/span&gt;(type, properties) {
&lt;span style="color: blue"&gt;    return this&lt;/span&gt;.each(&lt;span style="color: blue"&gt;function&lt;/span&gt;() {
        Sys.Component.create(type, properties, {}, {},&lt;span style="color: blue"&gt; this&lt;/span&gt;);
    });
};&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;I have another version that is a little more elaborate and takes a bag of properties and events instead of just properties (get it from the attached sample) but you get the idea. This makes it fairly easy to instantiate components based on a selector:&lt;/p&gt;

&lt;pre class="code"&gt;$(&lt;span style="color: #a31515"&gt;&amp;quot;:text.nomorethanfive&amp;quot;&lt;/span&gt;)
    .create(Bleroy.Sample.CharCount, { maxLength: 5 });&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;But if this were a native jQuery plugin instead of a Microsoft Ajax component, as &lt;a href="http://west-wind.com/weblog/"&gt;Rick Strahl&lt;/a&gt; suggested, chances are you’d do something like this instead:&lt;/p&gt;

&lt;pre class="code"&gt;$(&lt;span style="color: #a31515"&gt;&amp;quot;:text.nomorethanfive&amp;quot;&lt;/span&gt;).charCount({ maxLength: 5 });&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;We can actually get that exact result fairly easily by writing a plugin that is specific to this component, but we can’t expect every Microsoft Ajax component author to also write a jQuery plugin, can we? We can do better than that. Here is a second small piece of code that is still generic but is in the business of &lt;em&gt;creating jQuery plugins&lt;/em&gt;:&lt;/p&gt;

&lt;pre class="code"&gt;Sys.Component.exposeTojQuery = &lt;span style="color: blue"&gt;function&lt;/span&gt;(type, pluginName) {
    &lt;span style="color: blue"&gt;return &lt;/span&gt;jQuery.fn[pluginName] = &lt;span style="color: blue"&gt;function&lt;/span&gt;(properties) {
        &lt;span style="color: blue"&gt;return this&lt;/span&gt;.each(&lt;span style="color: blue"&gt;function&lt;/span&gt;() {
            Sys.Component.create(type, properties, {}, {}, &lt;span style="color: blue"&gt;this&lt;/span&gt;);
        });
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Like above, the version in the sample is better than that in that it supports events in addition to properties but again you get the idea. Thanks to this function, we can create a jQuery plugin for any existing Microsoft Ajax component with a single line of code:&lt;/p&gt;

&lt;pre class="code"&gt;Sys.Component.exposeTojQuery(Bleroy.Sample.CharCount, &lt;span style="color: #a31515"&gt;&amp;quot;charCount&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;After this call, we can write exactly the code we wrote before, but without having had to write a specific plugin. We can then use charCount like a native jQuery plugin:&lt;/p&gt;

&lt;pre class="code"&gt;$(&lt;span style="color: #a31515"&gt;&amp;quot;:text.nomorethanfive&amp;quot;&lt;/span&gt;).charCount({ maxLength: 5 });&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;This is really easy to use, and I quite like it. We could for example add the following line of code to the new MicrosoftAjaxTemplates.js:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(jQuery)&lt;br /&gt;    Sys.Component.exposeTojQuery(Sys.UI.DataView, &lt;span style="color: #a31515"&gt;&amp;quot;dataView&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;This would enable us to instantiate DataView controls as simply as this:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ul &lt;/span&gt;&lt;span style="color: red"&gt;class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;dv&amp;quot;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;li&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;{{ $dataItem }}&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;li&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ul&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;script &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text/javascript&amp;quot;&amp;gt;
&lt;/span&gt;    $(&lt;span style="color: #a31515"&gt;&amp;quot;.dv&amp;quot;&lt;/span&gt;).dataView({ data: [&lt;span style="color: #a31515"&gt;&amp;quot;foo&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;bar&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;baz&amp;quot;&lt;/span&gt;] });
&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;script&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Get the code from here (you need to include &lt;a href="http://docs.jquery.com/Downloading_jQuery"&gt;jquery-1.3.2.js&lt;/a&gt; to the script folder):

  &lt;br /&gt;&lt;a title="http://weblogs.asp.net/blogs/bleroy/Samples/jQueryCreate.zip" href="http://weblogs.asp.net/blogs/bleroy/Samples/jQueryCreate.zip"&gt;http://weblogs.asp.net/blogs/bleroy/Samples/jQueryCreate.zip&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7073206" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Atlas/default.aspx">Atlas</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category></item><item><title>Glimmer: visually build jQuery animations and stuff</title><link>http://weblogs.asp.net/bleroy/archive/2009/04/28/glimmer-visually-build-jquery-animations-and-stuff.aspx</link><pubDate>Tue, 28 Apr 2009 18:35:29 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7063913</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=7063913</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2009/04/28/glimmer-visually-build-jquery-animations-and-stuff.aspx#comments</comments><description>&lt;p&gt;&lt;a title="Glimmer" href="http://visitmix.com/Articles/Glimmer-a-jQuery-Interactive-Design-Tool"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="glim4s" border="0" alt="glim4s" align="left" src="http://weblogs.asp.net/blogs/bleroy/glim4s_380D1EFE.png" width="244" height="183" /&gt;&lt;/a&gt;If you’re still intimidated by jQuery or DOM manipulation in general, if you need to quickly build web animations, if you’re more a designer guy, if you think tooling makes sense, or a combination of the above, you should probably check out &lt;a href="http://visitmix.com/Articles/Glimmer-a-jQuery-Interactive-Design-Tool"&gt;Glimmer&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;In a nutshell, &lt;a href="http://visitmix.com/Articles/Glimmer-a-jQuery-Interactive-Design-Tool"&gt;Glimmer&lt;/a&gt; is a visual tool that builds HTML animations, menus, tooltips on jQuery. It builds all the code you need (HTML, CSS and JavaScript with jQuery) at the click of a button.&lt;/p&gt;  &lt;p&gt;Check it out!   &lt;br /&gt;&lt;a href="http://visitmix.com/Articles/Glimmer-a-jQuery-Interactive-Design-Tool"&gt;http://visitmix.com/Articles/Glimmer-a-jQuery-Interactive-Design-Tool&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7063913" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/CSS/default.aspx">CSS</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/HTML/default.aspx">HTML</category></item><item><title>VsDoc for jQuery 1.3.1 now available</title><link>http://weblogs.asp.net/bleroy/archive/2009/02/06/vsdoc-for-jquery-1-3-1-now-available.aspx</link><pubDate>Fri, 06 Feb 2009 21:53:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6889709</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=6889709</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2009/02/06/vsdoc-for-jquery-1-3-1-now-available.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://ejohn.org/"&gt;John Resig&lt;/a&gt; tells us he just uploaded the VsDoc file for jQuery 1.3.1 to &lt;a href="http://jquery.com"&gt;jquery.com&lt;/a&gt;. This enables IntelliSense for the latest available jQuery.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px; display: inline; border-top: 0px; border-right: 0px" title="jQuery VsDoc file for 1.3.1 available from jquery.com" border="0" alt="jQuery VsDoc file for 1.3.1 available from jquery.com" src="http://weblogs.asp.net/blogs/bleroy/jQueryJsDoc131_13C6BA00.png" width="237" height="104" /&gt; &lt;/p&gt;  &lt;p&gt;Download the file from the jQuery downloads page:   &lt;br /&gt;&lt;a href="http://docs.jquery.com/Downloading_jQuery#Download_jQuery"&gt;http://docs.jquery.com/Downloading_jQuery#Download_jQuery&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;More info on what this is:   &lt;br /&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2008/11/07/visual-studio-patched-for-better-jquery-intellisense.aspx"&gt;http://weblogs.asp.net/bleroy/archive/2008/11/07/visual-studio-patched-for-better-jquery-intellisense.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6889709" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category></item><item><title>JavaScript Behavior Sheets: an experiment</title><link>http://weblogs.asp.net/bleroy/archive/2009/01/18/javascript-behavior-sheets-an-experiment.aspx</link><pubDate>Sun, 18 Jan 2009 08:53:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6843536</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>18</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=6843536</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2009/01/18/javascript-behavior-sheets-an-experiment.aspx#comments</comments><description>&lt;P&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; MARGIN: 0px 7px 0px 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="(c) Bertrand Le Roy 2004" border=0 alt="(c) Bertrand Le Roy 2004" align=left src="http://weblogs.asp.net/blogs/bleroy/ZenShadows_7A57622D.jpg" width=164 height=244 mce_src="http://weblogs.asp.net/blogs/bleroy/ZenShadows_7A57622D.jpg"&gt; Here’s a little experiment. I’m really after feedback on this one as I’m trying to decide whether this is a good idea. It’s also entirely possible somebody else did this before. That would be good feedback too. Anyway, here it is.&lt;/P&gt;
&lt;P&gt;Despite its shortcomings, CSS has a number of features that make it very compelling. First, it decouples styling from markup. Second, its selector syntax is simple, yet reasonably powerful.&lt;/P&gt;
&lt;P&gt;So we have semantic markup on the one hand, and styles on the other hand, and the only coupling between the two is the selectors in the stylesheet.&lt;/P&gt;
&lt;P&gt;In Ajax applications, there is a third kind of entity in the mix, JavaScript behavior. There are of course ways to decouple the script behavior from the markup, which are usually referred to as &lt;A href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript" mce_href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript"&gt;unobtrusive JavaScript&lt;/A&gt;. &lt;A href="http://www.jquery.com/" mce_href="http://www.jquery.com"&gt;jQuery&lt;/A&gt; &lt;FONT face="Courier New"&gt;also &lt;/FONT&gt;introduced back in 2005 a way to associate script behavior with the DOM using the same selector syntax that CSS uses.&lt;/P&gt;
&lt;P&gt;But way before &lt;A href="http://jquery.com/" mce_href="http://jquery.com/"&gt;jQuery&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/ms532147.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms532147.aspx"&gt;Internet Explorer 5 enabled developers to specify behavior in stylesheets&lt;/A&gt;. You could do this for example:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: #a31515"&gt;.hilite &lt;/SPAN&gt;{ &lt;SPAN style="COLOR: red"&gt;behavior&lt;/SPAN&gt;:&lt;SPAN style="COLOR: blue"&gt;url(hilite.htc) &lt;/SPAN&gt;}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;This was a pretty neat idea at the time despite the challenges that came with it (in terms of performance for example), but it was never adopted by the other browsers despite having been &lt;A href="http://www.w3.org/TR/1999/WD-becss-19990804.html" mce_href="http://www.w3.org/TR/1999/WD-becss-19990804.html"&gt;submitted to W3C&lt;/A&gt;. The feature was never very widely used. There *is* &lt;A href="http://dean.edwards.name/moz-behaviors/overview/" mce_href="http://dean.edwards.name/moz-behaviors/overview/"&gt;a Firefox implementation of HTC behaviors&lt;/A&gt; but it doesn’t seem to have helped much in terms of adoption of this feature.&lt;/P&gt;
&lt;P&gt;And one thing that bothers me with that idea is that while it does decouple behavior from markup, it also &lt;EM&gt;couples&lt;/EM&gt; behavior to styling at least in location. Putting styles and behavior in the same file, in retrospect, looks like one step forward, and one step backwards. Sure, you could always use two separate files but the system did nothing to encourage you to do that.&lt;/P&gt;
&lt;P&gt;What I’m trying to do here is separate styling, markup *and* behavior, leverage selectors in a nice, declarative way &lt;EM&gt;à la&lt;/EM&gt; CSS and still work on all modern browsers. The coupling mechanism between style and markup (CSS selectors), is reasonably good and is already known by all Web developers so it remains a natural choice as jQuery showed clearly. Let’s see if one can express behavior in a way that is close to the already well-known CSS pattern.&lt;/P&gt;
&lt;P&gt;In this implementation, it is possible to add event handlers and Microsoft Ajax behaviors from a “JavaScript Behavior Sheet” which can be embedded in the page or be loaded from a separate file using a modified script tag:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;script &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="text/behavior" &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;src&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="BehaviorSheet.jss"&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;script&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;The contents of the tag or file is in the simple JSON notation for an object, omitting the curly braces:&lt;/P&gt;&lt;PRE class=code&gt;"input[type=text].nomorethanfive": {
    click: function(e) {
        alert("You clicked input #" + e.target.id);
    },
    "Bleroy.Sample.CharCount": {
        maxLength: 5,
        overflow: function(source, args) {
            $(source.get_element()).jFade({
                 property: 'background',
                 start: 'FFFF00',
                 end: 'FFFFFF',
                 steps: 25,
                 duration: 30
            });
        }
    }
}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;The top-level entities that can be found in there are the CSS selectors (note the quotes that &lt;EM&gt;are&lt;/EM&gt; a departure from CSS notation but made the prototyping so much simpler). Each selector is associated with an object that contains event and object definitions.&lt;/P&gt;
&lt;P&gt;The event definitions consist in the event name and the handler to associate with it:&lt;/P&gt;&lt;PRE class=code&gt;click: function(e) {
    alert("You clicked input #" + e.target.id);
},&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;The implementation of this feature uses the new &lt;A href="http://docs.jquery.com/Events/live#typefn" mce_href="http://docs.jquery.com/Events/live#typefn"&gt;live events from jQuery&lt;/A&gt;. The result of that definition is that clicking on any input of type text with the class “nomorethanfive” will display an alert giving the id of the input that was clicked. That is a pretty efficient way to hook up events to multiple elements…&lt;/P&gt;
&lt;P&gt;The behavior instantiation specifies the class to instantiate, “Bleroy.Sample.CharCount” and lists the properties, fields and events to set (here, the maxLength property is set to 5 and the overflow event is hooked to a function that flashes the element’s background yellow):&lt;/P&gt;&lt;PRE class=code&gt;"Bleroy.Sample.CharCount": {
    maxLength: 5,
    overflow: function(source, args) {
        $(source.get_element()).jFade({
             property: 'background',
             start: 'FFFF00',
             end: 'FFFFFF',
             steps: 25,
             duration: 30
        });
    }
}&lt;/PRE&gt;
&lt;P&gt;Here’s what the page looks like: &lt;BR&gt;&lt;/P&gt;
&lt;DIV style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id=scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:beb84b52-ccf2-4861-9ec4-3bb1f8e468bc class=wlWriterEditableSmartContent&gt;
&lt;DIV style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-TOP: 0px" id=4314ce20-b9b6-441e-9466-068510fa6144&gt;
&lt;DIV&gt;&lt;A href="http://video.msn.com/video.aspx?vid=bd271e94-33e0-46fd-a09f-17c5ebe09f11" target=_new&gt;&lt;IMG style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-TOP-STYLE: none; BORDER-LEFT-STYLE: none" alt="" src="http://weblogs.asp.net/blogs/bleroy/videofbd13523437b_5803F39D.jpg" onload="var downlevelDiv = document.getElementById('4314ce20-b9b6-441e-9466-068510fa6144'); downlevelDiv.innerHTML = &amp;quot;&lt;div&gt;&lt;embed src=\&amp;quot;http://images.video.msn.com/flash/soapbox1_1.swf\&amp;quot; quality=\&amp;quot;high\&amp;quot; width=\&amp;quot;432\&amp;quot; height=\&amp;quot;364\&amp;quot; wmode=\&amp;quot;transparent\&amp;quot; type=\&amp;quot;application/x-shockwave-flash\&amp;quot; pluginspage=\&amp;quot;http://macromedia.com/go/getflashplayer\&amp;quot; flashvars=\&amp;quot;c=v&amp;amp;v=bd271e94-33e0-46fd-a09f-17c5ebe09f11&amp;amp;from=writer&amp;amp;mkt=en-US\&amp;quot; &gt;&lt;\/embed&gt;&lt;\/div&gt;&amp;quot;;" galleryimg="no"&gt;&lt;/A&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;I should point out that while the events will handle DOM mutations (such as adding new elements that match the selector) just fine, component instantiation won’t in this implementation, which is a limitation that is quite hard to work around in current browsers.&lt;/P&gt;
&lt;P&gt;So here it is. All the code for this is &lt;A href="http://weblogs.asp.net/blogs/bleroy/Samples/BehaviorSheet.zip" mce_href="http://weblogs.asp.net/blogs/bleroy/Samples/BehaviorSheet.zip"&gt;available from the link below&lt;/A&gt; (contains &lt;A href="http://www.gimiti.com/kltan/wordpress/?p=43" mce_href="http://www.gimiti.com/kltan/wordpress/?p=43"&gt;jFade&lt;/A&gt;, code licensed under &lt;A href="http://opensource.org/licenses/mit-license.php" mce_href="http://opensource.org/licenses/mit-license.php"&gt;MIT&lt;/A&gt;: &lt;A href="http://jquery.com/" mce_href="http://jquery.com/"&gt;jQuery&lt;/A&gt;, and code under &lt;A href="http://opensource.org/licenses/ms-pl.html" mce_href="http://opensource.org/licenses/ms-pl.html"&gt;MS-PL&lt;/A&gt;: &lt;A href="http://www.asp.net/ajax/" mce_href="http://www.asp.net/ajax/"&gt;Microsoft Ajax&lt;/A&gt; and my own code), with some tests written with &lt;A href="http://weblogs.asp.net/bleroy/archive/2008/12/09/really-simple-testing-for-javascript.aspx" mce_href="http://weblogs.asp.net/bleroy/archive/2008/12/09/really-simple-testing-for-javascript.aspx"&gt;RST.js&lt;/A&gt;. So what do you think?&lt;/P&gt;
&lt;P&gt;&lt;A title=http://weblogs.asp.net/blogs/bleroy/Samples/BehaviorSheet.zip href="http://weblogs.asp.net/blogs/bleroy/Samples/BehaviorSheet.zip" mce_href="http://weblogs.asp.net/blogs/bleroy/Samples/BehaviorSheet.zip"&gt;http://weblogs.asp.net/blogs/bleroy/Samples/BehaviorSheet.zip&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;UPDATE:&lt;/STRONG&gt; interestingly, the intent behind &lt;A href="http://code.google.com/p/reglib/"&gt;Reglib&lt;/A&gt; by &lt;A href="http://blogs.sun.com/greimer/"&gt;Greg Reimer&lt;/A&gt; is pretty close to this and he even uses the words “Behavior Sheets”.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;UPDATE:&lt;/STRONG&gt; Stuart Langridge did &lt;A href="http://www.kryogenix.org/code/browser/jses/" mce_href="http://www.kryogenix.org/code/browser/jses/"&gt;something very close to declarative events as they are done here&lt;/A&gt; &lt;EM&gt;back in November 2003&lt;/EM&gt;. Thanks to Clayton for pointing that out. One should note that the limitations of the time are no longer preventing the technique from reaching its full potential.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6843536" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/Firefox/default.aspx">Firefox</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Atlas/default.aspx">Atlas</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JSON/default.aspx">JSON</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/HTML/default.aspx">HTML</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category></item><item><title>Wally’s introduction to 3.5 SP1</title><link>http://weblogs.asp.net/bleroy/archive/2008/12/29/wally-s-introduction-to-3-5-sp1.aspx</link><pubDate>Mon, 29 Dec 2008 19:36:18 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6808745</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=6808745</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2008/12/29/wally-s-introduction-to-3-5-sp1.aspx#comments</comments><description>&lt;p&gt;Wally McClure, MVP extraordinaire and ASP Insider, just published &lt;a href="http://www.wrox.com/WileyCDA/WroxTitle/New-Features-in-ASP-NET-3-5-Service-Pack-1.productCd-0470457341.html"&gt;a short book about the new features in ASP.NET 3.5 SP1&lt;/a&gt;. It is a short and to the point read that should get you started in no time. I wouldn’t have shown web service access as the main advantage of &lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt; myself (the selector and animation support adds more value for ASP.NET Ajax developers) but that’s a minor thing, and there are &lt;a href="http://docs.jquery.com/Main_Page"&gt;plenty of&lt;/a&gt; &lt;a href="http://docs.jquery.com/Tutorials"&gt;other resources&lt;/a&gt; to learn about &lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;. Topics in Wally’s book include:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Ajax History&lt;/li&gt;    &lt;li&gt;Script Combining (including ScriptReferenceProfiler)&lt;/li&gt;    &lt;li&gt;&lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Routing&lt;/li&gt;    &lt;li&gt;Entity Framework&lt;/li&gt;    &lt;li&gt;Dynamic Data&lt;/li&gt;    &lt;li&gt;ADO.NET Data Services&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://www.wrox.com/WileyCDA/WroxTitle/New-Features-in-ASP-NET-3-5-Service-Pack-1.productCd-0470457341.html"&gt;http://www.wrox.com/WileyCDA/WroxTitle/New-Features-in-ASP-NET-3-5-Service-Pack-1.productCd-0470457341.html&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6808745" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Atlas/default.aspx">Atlas</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/ADO.NET+Data+Services/default.aspx">ADO.NET Data Services</category></item><item><title>Microsoft Ajax Client Templates and declarative jQuery</title><link>http://weblogs.asp.net/bleroy/archive/2008/12/09/microsoft-ajax-client-templates-and-declarative-jquery.aspx</link><pubDate>Wed, 10 Dec 2008 07:33:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6776267</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=6776267</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2008/12/09/microsoft-ajax-client-templates-and-declarative-jquery.aspx#comments</comments><description>&lt;p&gt;Apparently &lt;a href="http://weblogs.manas.com.ar/bcardiff"&gt;Brian&lt;/a&gt; likes our declarative syntax. And &lt;a href="http://www.jquery.com"&gt;jQuery&lt;/a&gt;. And he did &lt;a href="http://weblogs.manas.com.ar/bcardiff/2008/12/declarative-jquery-with-microsoft-ajax/"&gt;something quite fun&lt;/a&gt; with them, something we had clearly not anticipated: &lt;a href="http://weblogs.manas.com.ar/bcardiff/2008/12/declarative-jquery-with-microsoft-ajax/"&gt;using Microsoft Ajax’s new declarative syntax to call jQuery plug-ins&lt;/a&gt; instead of Microsoft Ajax behaviors as was the original intent.&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;input &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;text&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;maxlength&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;20&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;size&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;40&amp;quot; 
   &lt;/span&gt;&lt;span style="color: #a31515"&gt;sys&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;key&lt;/span&gt;&lt;span style="color: blue"&gt;=”self” 
   &lt;/span&gt;&lt;span style="color: #a31515"&gt;sys&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;attach&lt;/span&gt;&lt;span style="color: blue"&gt;=”wajbar”  
   &lt;/span&gt;&lt;span style="color: #a31515"&gt;wajbar&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;submit&lt;/span&gt;&lt;span style="color: blue"&gt;=”{{ &lt;/span&gt;$&lt;span style="color: blue"&gt;(&lt;/span&gt;&lt;span style="color: red"&gt;self&lt;/span&gt;&lt;span style="color: blue"&gt;)&lt;/span&gt;&lt;span style="color: red"&gt;.next&lt;/span&gt;&lt;span style="color: blue"&gt;(&lt;/span&gt;&lt;span style="color: #a31515"&gt;’input&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;submit’&lt;/span&gt;&lt;span style="color: blue"&gt;) &lt;/span&gt;}}&lt;span style="color: red"&gt;” &lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt; 
&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;What do you think?&lt;/p&gt;

&lt;p&gt;Brian’s post:
  &lt;br /&gt;&lt;a title="http://weblogs.manas.com.ar/bcardiff/2008/12/declarative-jquery-with-microsoft-ajax/" href="http://weblogs.manas.com.ar/bcardiff/2008/12/declarative-jquery-with-microsoft-ajax/"&gt;http://weblogs.manas.com.ar/bcardiff/2008/12/declarative-jquery-with-microsoft-ajax/&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6776267" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Atlas/default.aspx">Atlas</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category></item><item><title>Visual Studio patched for better jQuery IntelliSense</title><link>http://weblogs.asp.net/bleroy/archive/2008/11/07/visual-studio-patched-for-better-jquery-intellisense.aspx</link><pubDate>Sat, 08 Nov 2008 05:34:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6726221</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>16</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=6726221</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2008/11/07/visual-studio-patched-for-better-jquery-intellisense.aspx#comments</comments><description>&lt;p&gt;Jeff King just announced the release of a &lt;a href="http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736"&gt;patch&lt;/a&gt; for Visual Studio 2008 that enables the IDE to find the –vsdoc.js file without requiring the developer to reference it.&lt;/p&gt;  &lt;p&gt;To give some context, a documentation file (basically the same file as the runtime script but with &lt;a href="http://weblogs.asp.net/bleroy/archive/2007/04/23/the-format-for-javascript-doc-comments.aspx"&gt;XML documentation annotations&lt;/a&gt;) can be provided to help Visual Studio provide IntelliSense. Until now, you had to reference that extra file explicitly, usually within a server-side &amp;lt;% if %&amp;gt; block so that the file never gets included at runtime.&lt;/p&gt;  &lt;p&gt;Now that this patch shipped, this is no longer necessary and Visual Studio is going to be able to find the –vsdoc.js file for any script file that is referenced, whether that is through a ScriptManager ScriptReference:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="jQueryIntelliSenseScriptReference" border="0" alt="jQueryIntelliSenseScriptReference" src="http://weblogs.asp.net/blogs/bleroy/jQueryIntelliSenseScriptReference_211932DA.png" width="504" height="131" /&gt; &lt;/p&gt;  &lt;p&gt;or using a plain script tag:   &lt;br /&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="jQueryIntelliSenseScriptTag" border="0" alt="jQueryIntelliSenseScriptTag" src="http://weblogs.asp.net/blogs/bleroy/jQueryIntelliSenseScriptTag_1BC6382A.png" width="504" height="256" /&gt; &lt;/p&gt;  &lt;p&gt;or even a reference XML tag:   &lt;br /&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="jQueryIntelliSenseReferenceTag" border="0" alt="jQueryIntelliSenseReferenceTag" src="http://weblogs.asp.net/blogs/bleroy/jQueryIntelliSenseReferenceTag_253EF6A0.png" width="504" height="233" /&gt; &lt;/p&gt;  &lt;p&gt;That makes jQuery IntelliSense as easy as dropping the –vsdoc.js file in the web site next to the main jQuery file (other libraries can easily take advantage of that too of course):   &lt;br /&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="jQueryIntelliSenseFileLocation" border="0" alt="jQueryIntelliSenseFileLocation" src="http://weblogs.asp.net/blogs/bleroy/jQueryIntelliSenseFileLocation_1145640A.png" width="269" height="182" /&gt; &lt;/p&gt;  &lt;p&gt;Pretty sweet.&lt;/p&gt;  &lt;p&gt;The patch can be found here:   &lt;br /&gt;&lt;a title="http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736" href="http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736"&gt;http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The IntelliSense file for jQuery can be downloaded from the jQuery servers (look for the “documentation: Visual Studio” file):   &lt;br /&gt;&lt;a title="http://docs.jquery.com/Downloading_jQuery#Download_jQuery" href="http://docs.jquery.com/Downloading_jQuery#Download_jQuery"&gt;http://docs.jquery.com/Downloading_jQuery#Download_jQuery&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Jeff’s post:   &lt;br /&gt;&lt;a title="http://blogs.msdn.com/webdevtools/archive/2008/11/07/hotfix-to-enable-vsdoc-js-intellisense-doc-files-is-now-available.aspx" href="http://blogs.msdn.com/webdevtools/archive/2008/11/07/hotfix-to-enable-vsdoc-js-intellisense-doc-files-is-now-available.aspx"&gt;http://blogs.msdn.com/webdevtools/archive/2008/11/07/hotfix-to-enable-vsdoc-js-intellisense-doc-files-is-now-available.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Jeff’s other post on using the documentation file:   &lt;br /&gt;&lt;a title="http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx" href="http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx"&gt;http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The format for XML doc comments:   &lt;br /&gt;&lt;a title="http://weblogs.asp.net/bleroy/archive/2007/04/23/the-format-for-javascript-doc-comments.aspx" href="http://weblogs.asp.net/bleroy/archive/2007/04/23/the-format-for-javascript-doc-comments.aspx"&gt;http://weblogs.asp.net/bleroy/archive/2007/04/23/the-format-for-javascript-doc-comments.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6726221" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/IntelliSense/default.aspx">IntelliSense</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category></item><item><title>PDC 2008 ASP.NET AJAX Futures talk available online</title><link>http://weblogs.asp.net/bleroy/archive/2008/11/03/pdc-2008-asp-net-ajax-futures-talk-available-online.aspx</link><pubDate>Mon, 03 Nov 2008 18:10:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6718193</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=6718193</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2008/11/03/pdc-2008-asp-net-ajax-futures-talk-available-online.aspx#comments</comments><description>&lt;P&gt;The full 83 minutes of &lt;A href="http://channel9.msdn.com/pdc2008/PC32/" mce_href="http://channel9.msdn.com/pdc2008/PC32/"&gt;my PDC talk&lt;/A&gt; are available on &lt;A href="http://channel9.msdn.com/" mce_href="http://channel9.msdn.com"&gt;the Channel 9 web site&lt;/A&gt;. You can &lt;A href="http://channel9.msdn.com/pdc2008/PC32/" mce_href="http://channel9.msdn.com/pdc2008/PC32/"&gt;watch the session online&lt;/A&gt; (using Silverlight) or download the video in a number of formats. &lt;A href="http://mschnlnine.vo.llnwd.net/d1/pdc08/PPTX/PC32.pptx" mce_href="http://mschnlnine.vo.llnwd.net/d1/pdc08/PPTX/PC32.pptx"&gt;Slides&lt;/A&gt; and &lt;A href="http://mschnlnine.vo.llnwd.net/d1/pdc08/ZIP/PC32.ZIP" mce_href="http://mschnlnine.vo.llnwd.net/d1/pdc08/ZIP/PC32.ZIP"&gt;source code for the demo&lt;/A&gt; are also available.&lt;/P&gt;
&lt;P&gt;&lt;A title="Watch the PDC 2008 ASP.NET AJAX Futures talk." href="http://channel9.msdn.com/pdc2008/PC32/" mce_href="http://channel9.msdn.com/pdc2008/PC32/"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title="PDC 2008 ASP.NET AJAX Futures" border=0 alt="PDC 2008 ASP.NET AJAX Futures" src="http://weblogs.asp.net/blogs/bleroy/image_49E75279.png" width=504 height=258 mce_src="http://weblogs.asp.net/blogs/bleroy/image_49E75279.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Watch online: &lt;BR&gt;&lt;A title=http://channel9.msdn.com/pdc2008/PC32/ href="http://channel9.msdn.com/pdc2008/PC32/" mce_href="http://channel9.msdn.com/pdc2008/PC32/"&gt;http://channel9.msdn.com/pdc2008/PC32/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Download &lt;A href="http://mschnlnine.vo.llnwd.net/d1/pdc08/mp4/PC32.mp4" mce_href="http://mschnlnine.vo.llnwd.net/d1/pdc08/mp4/PC32.mp4"&gt;MP4 / iPod&lt;/A&gt;, &lt;A href="http://mschnlnine.vo.llnwd.net/d1/pdc08/ZUNE/PC32.wmv" mce_href="http://mschnlnine.vo.llnwd.net/d1/pdc08/ZUNE/PC32.wmv"&gt;Zune&lt;/A&gt;, &lt;A href="http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV/PC32.wmv" mce_href="http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV/PC32.wmv"&gt;WMV&lt;/A&gt; or &lt;A href="http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV-HQ/PC32.wmv" mce_href="http://mschnlnine.vo.llnwd.net/d1/pdc08/WMV-HQ/PC32.wmv"&gt;WMV-HQ&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Slides: &lt;BR&gt;&lt;A title=http://mschnlnine.vo.llnwd.net/d1/pdc08/PPTX/PC32.pptx href="http://mschnlnine.vo.llnwd.net/d1/pdc08/PPTX/PC32.pptx" mce_href="http://mschnlnine.vo.llnwd.net/d1/pdc08/PPTX/PC32.pptx"&gt;http://mschnlnine.vo.llnwd.net/d1/pdc08/PPTX/PC32.pptx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Demo code (contains MIT and MS-PL licensed JavaScript files): &lt;BR&gt;&lt;A title=http://mschnlnine.vo.llnwd.net/d1/pdc08/ZIP/PC32.ZIP href="http://mschnlnine.vo.llnwd.net/d1/pdc08/ZIP/PC32.ZIP" mce_href="http://mschnlnine.vo.llnwd.net/d1/pdc08/ZIP/PC32.ZIP"&gt;http://mschnlnine.vo.llnwd.net/d1/pdc08/ZIP/PC32.ZIP&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://channel9.msdn.com/pdc2008/PC31/" mce_href="http://channel9.msdn.com/pdc2008/PC31/"&gt;Another talk you may be interested in is Stephen Walther's&lt;/A&gt;. Stephen did an amazing job explaining how jQuery and ASP.NET Ajax work and fit together. The talk is very accessible even if you have no prior knowledge of jQuery: &lt;A href="http://channel9.msdn.com/pdc2008/PC31/"&gt;http://channel9.msdn.com/pdc2008/PC31/&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6718193" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Ajax+Control+Toolkit/default.aspx">Ajax Control Toolkit</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Atlas/default.aspx">Atlas</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JSON/default.aspx">JSON</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/PDC/default.aspx">PDC</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/HTML/default.aspx">HTML</category></item><item><title>ASP.NET 4.0 Roadmap talk available online</title><link>http://weblogs.asp.net/bleroy/archive/2008/10/28/asp-net-4-0-roadmap-talk-available-online.aspx</link><pubDate>Tue, 28 Oct 2008 22:09:26 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6708711</guid><dc:creator>Bertrand Le Roy</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bleroy/rsscomments.aspx?PostID=6708711</wfw:commentRss><comments>http://weblogs.asp.net/bleroy/archive/2008/10/28/asp-net-4-0-roadmap-talk-available-online.aspx#comments</comments><description>&lt;p&gt;Scott Hunter’s talk on the ASP.NET 4.0 roadmap (in which I’m doing a 10 minute demo) is available from Channel9:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://channel9.msdn.com/pdc2008/PC20/" href="http://channel9.msdn.com/pdc2008/PC20/"&gt;http://channel9.msdn.com/pdc2008/PC20/&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6708711" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/bleroy/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Atlas/default.aspx">Atlas</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/Microsoft+AJAX+Library/default.aspx">Microsoft AJAX Library</category><category domain="http://weblogs.asp.net/bleroy/archive/tags/MVC/default.aspx">MVC</category></item></channel></rss>