Wednesday, June 3, 2009

Live Data Binding using ASP.NET AJAX 4.0

Introduction
Many of you may already be familiar with the upcoming version of ASP.NET AJAX, version 4.0. The release was out on March 12, 2009. The key features for this version are:

  • ADO.NET Data Services support
  • WCF and ASMX Web service integration
  • ASP.NET AJAX Client Templates
  • Declarative instantiation of client-side controls and behaviors
  • Observable pattern for plain JavaScript objects
  • Live Bindings
  • Markup Extensions
  • DataView control and DataContext component
  • Command Bubbling
  • Change tracking and identity management
  • Support for managing complex links and associations between entities from multiple entity sets or tables
  • Extension methods allowing change tracking and read-write client-server scenarios using other JSON services, including RESTful or JSONP based services
This preview version can be downloaded from here. This writing is mostly for highlighting the "Live Binding" feature introduced in this release of ASP.NET AJAX. This will also cover some operations on DataView control and DataContext component.

What is Live Binding?

Live binding is having the data bound in real-time. Meaning when there's any change in the data source, the changes are reflected to the data bound interface instantly and vice versa. For example if you have an interface component, like a table, bound to a data source, like an array, any change to that array from the code is reflected in the view table instantly. If you are using an edit template for updating the data of a selected row of the table, the data in the table will get updated as you change a field in your edit form if both the table and the form use "Live Binding".
span >Pretty cool, right?

Inside Live Binding

This is all done through client-side script, JavaScript. But how does it come in action? The core of the live binding is the implementation of an "Observer" pattern. The observer pattern enables an object to be notified about changes that occur in another object. This is not an event handler based pattern which we often misuse as an observer pattern. ASP.NET AJAX 4.0 implements this pattern completely. It adds observer functionality to ordinary JavaScript objects or arrays so that they raise change notifications when they are modified through the Sys.Observer interface.

Live Binding in Action

To implement live binding, you will need the ASP.NET AJAX 4.0 framework included in your file. After downloading from here, you'll need to reference them to your file. You can use a conventional

see full detail: http://dotnetslackers.com/articles/ajax/Live-Data-Binding-using-ASP-NET-AJAX-4-0-Preview-4.aspx

No comments: