11.12. Sys.Observer

A common problem when designing web applications is the need to refresh the UI in response to changes in an underlying data source. You might have accomplished this by polling an object or service for changes, but you now have a better option with the Sys.Observer functionality. The Sys.Observer functionality is Microsoft AJAX libraries' implementation of the popular Observer pattern.

You will now write some example code to tell ASP.NET AJAX to monitor an array of numbers and refresh the template if anything changes to the array. You will then create a function that adds a random number to the array and note how the result is returned:

  1. Copy and paste the file dataviewDeclarative.htm, and rename the copy to observer.htm.

Get Introducing .NET 4.0: with Visual Studio 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.