Update Panel .NET

Exploring Microsoft ASP.NET AJAX and jQuery

Archive for September 2008

Microsoft and jQuery

leave a comment »

Back in July, Microsoft published the ASP.NET AJAX Roadmap in which they mentioned the following features:

  • CSS 2.1 DOM selection with support for native querySelector APIs.
  • Chainable DOM generation and manipulation APIs.
  • CSS selector-based event sink so that it becomes possible to set-up an event for all elements that satisfy a given selector at the time when the sink is created and later. 

I wondered why Microsoft doesn’t just include jQuery instead of reinventing the wheel.  So I was pleasantly surprised when Microsoft announced that they are going to include and support jQuery afterall.

jQuery plays well with Microsoft AJAX Library (actually it should be the other way round since jQuery precedes Microsoft AJAX Library) – Microsoft AJAX Library offers great component building, extensibility and interoperability with ASP.NET web services, and jQuery offers simple yet powerful DOM selection and manipulation APIs.

Written by tzkuei

September 29, 2008 at 6:13 pm

Posted in DOM, JavaScript

if (typeof Sys !== “undefined”) redundant?

leave a comment »

In all Microsoft’s sample code, the last line in your client-script file is usually:

if (typeof Sys !== "undefined") Sys.Application.notifyScriptLoaded();

But what is the point in checking to see if “Sys” is undefined? Surely if it wasn’t defined, the first line of your script, usually the namespace declaration, would fail anyway, because the “Type” object will also be undefined, since both “Type” and “Sys” objects are defined in MicrosoftAjax.js.

So unless you want to split them up, I mean, why would you do that? I think that check is redundant!

Written by tzkuei

September 23, 2008 at 1:32 pm

Client-side templating and data-binding

leave a comment »

When ASP.NET AJAX 4.0 CodePlex Preview was released, I was particularly interested in Microsoft’s re-introduction and implementation of client-side data and templates.

The templates are declared in the mark-up, identified by a CSS class named “sys-template”.  When the page is loaded, the templates are parsed by the browser into the DOM.  The Microsoft AJAX Library then “parses” the template structure from the DOM and generates JavaScript code to re-create the template structure using DOM API.

The reason they choose to do it this way is because using DOM API is a safer and a more generic solution than concatenating strings and set innerHTML, also in IE, innerHTML is read-only for TABLE tags.

In a later post, I’ll demonstrate how you can create an extender to “AJAXify” your existing Repeater controls. 

Also in the preview is “live binding” where you can bind properties of control A to B and to C and have changes propagated from A to C.  I have personally implemented a simple and effective properties binding solution by utilising the ”propertyChanged” event of Sys.Component.  I will share it with you in a future post.

Written by tzkuei

September 1, 2008 at 6:03 pm