Archives

Archives / 2007 / March
  • Microsoft joins OpenAjax

    OpenAjaxI'm extremely pleased to announce that we're joining OpenAjax today and that I'll represent the company in the organization's meetings starting this Thursday. This is a way for us to ensure that our user community can combine the Microsoft AJAX Library and ASP.NET 2.0 AJAX Extensions with other frameworks, today and in the future. Interoperability in the browser is a hard problem but it opens key Ajax scenarios. An industry-wide organization such as OpenAjax is a great way to ensure this goal is met in the long-term.

    Read more...

  • What are these Foo$Bar$baz functions in the Microsoft Ajax Library files?

    If you've looked at the debug version of our JavaScript files, you may have noticed code similar to that:

    Foo.Bar = function Foo$Bar() {
    	Foo.Bar.initializeBase(this);
    }
    function Foo$Bar$baz() {
    	// Do something
    }
    Foo.Bar.prototype = {
    	baz: Foo$Bar$baz
    }
    Foo.Bar.registerClass('Foo.Bar');	

    And looking at that, you may have wondered what the Foo$Bar$baz names were for. That's a very good question and I congratulate you on your thoroughness. Here's why:
    Stack trace shows anonymous functions

    "JScript anonymous function"? That's not very helpful in a debugger stack trace and that's what you'd get if we had written the above code this way (or run the release version of the script):

    Foo.Bar = function() {
    	Foo.Bar.initializeBase(this);
    }
    Foo.Bar.prototype = {
    	baz: function() {
    		// Do something
    	}
    }
    Foo.Bar.registerClass('Foo.Bar'); 

    In this case, the methods on class instances are anonymous methods.

    Thanks to the global "dollared" names that we inject into the debug code, the functions have a global name that is easy to map to the actual member that they are aliases for, and here's what a typical stack trace looks like in debug mode:
    Stack trace shows meaningful function names

    That's of course a lot more useful. Of course, you should never use those names in code that consumes those libraries, as they are here only to make debugging easier and they won't be there if you run the release versions of the scripts (which you are doing on your production servers, right?). For example, Foo$Bar$baz in the above example is an alias for Foo.Bar.prototype.baz, which is what you should use if you need it. Most of the time, you'll just call baz off an instance, like this: myBar.baz().

    Finally, you may wonder why we're not writing this (which would be more compact and maybe a little easier to read):

    Foo.Bar = function Foo$Bar() {
    	Foo.Bar.initializeBase(this);
    }
    Foo.Bar.prototype = {
    	baz: function Foo$Bar$baz() {
    		// Do something
    	}
    }
    Foo.Bar.registerClass('Foo.Bar'); 

    Well, that would be great, but our good friend Safari 2 refuses to parse it... Safari 3 seems to fix that bug though.

    Read more...

  • UpdatePanel PDF updated for ASP.NET Ajax 1.0

    ASP.NET AJAX UpdatePanel Control: Add Ajax interactivity to your ASP.NET 2.0 web pagesThe PDF document that I wrote with Matt Gibbs a while ago on UpdatePanel is now up to date and in sync with the RTW (Release to Web) version of the ASP.NET 2.0 Ajax Extensions. It's a 60 page document that teaches how to use the UpdatePanel control to incrementally "ajaxify" an ASP.NET 2.0 web site. The booklet comes with downloadable code samples that are immediately applicable in the real world.

    Read more...

  • ASP.NET Ajax-aware JavaScript IntelliSense available from the Orcas CTP

    This is an absolutely awesome feature. IntelliSense / autocompletion for JavaScript is a difficult problem (because of the dynamic nature of JavaScript) which the Visual Studio team is brilliantly solving. They were able to build an elegant solution to the problem that works reasonably well on plain JavaScript, but really shines when used with ASP.NET Ajax. The type information that we added to our debug scripts through doc comments really helps in making the whole experience seamless.

    Read more...