<?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>Fredrik Normén : AXAJ</title><link>http://weblogs.asp.net/fredriknormen/archive/tags/AXAJ/default.aspx</link><description>Tags: AXAJ</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>ASP.NET AJAX 4.0 Preview 5 – Working with Converters and the new CDN</title><link>http://weblogs.asp.net/fredriknormen/archive/2009/09/16/asp-net-ajax-4-0-preview-5-working-with-converters-and-the-new-cdn.aspx</link><pubDate>Wed, 16 Sep 2009 21:01:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7208540</guid><dc:creator>Fredrik N</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/fredriknormen/rsscomments.aspx?PostID=7208540</wfw:commentRss><comments>http://weblogs.asp.net/fredriknormen/archive/2009/09/16/asp-net-ajax-4-0-preview-5-working-with-converters-and-the-new-cdn.aspx#comments</comments><description>&lt;P&gt;In this blog post I’m going to show you how you can use the new Converter feature during data binding, to make this post more special I have used the new Microsoft AJAX CDN (Content Delivery Network), so I don’t need to have the AJAX 4.0 script on my server. The example code I use in this post, will use the ASP.NET AJAX DataView and also Microsoft ADO.NET Data Services to retrieve data from the server. My fantasy isn’t so special good, but I decided to make a little “rental” application, where I will use ASP.NET AJAX to simply show a list of cars and the current rental status. The status of a rental car will be sent to the client as a string and can be of the following values, Approved, Not Approved and Pending. The little app I’m building for this post, will show the rental status as different colors for the user. &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/fredriknormen/image_2FA7CAA1.png" mce_href="http://weblogs.asp.net/blogs/fredriknormen/image_2FA7CAA1.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://weblogs.asp.net/blogs/fredriknormen/image_thumb_72A3990E.png" width=392 height=390 mce_src="http://weblogs.asp.net/blogs/fredriknormen/image_thumb_72A3990E.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Green color will show that the rental of the car is approved, red will indicate not approved and yellow will indicate a pending status. My little database have one simple table, called Rental (lack of fantasy), with three columns, ID, Description and Status. I have used Entity Framework together with ADO.Net Data Source to get the data from the database. Here is the ADO.NET Data Service, I have added a Rental operation to only enable access to the operation to get Rental entities. &lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; RentalWebDataService : DataService&amp;lt;RentalModel.RentalEntities&amp;gt;
{
    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; InitializeService(IDataServiceConfiguration config)
    {
        config.SetEntitySetAccessRule(&lt;SPAN class=str&gt;"Rental"&lt;/SPAN&gt;, EntitySetRights.AllRead);
        config.SetServiceOperationAccessRule(&lt;SPAN class=str&gt;"Rental"&lt;/SPAN&gt;, ServiceOperationRights.AllRead);
    }

    [WebGet]
    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; IQueryable&amp;lt;RentalModel.Rental&amp;gt; Rental()
    {
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.CurrentDataSource.Rental;
    }
}&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;To use ASP.NET AJAX 4.0 Preview 5, I have not used my local scripts, instead use the new Microsoft AJAX CDN. The Microsoft CDN service provides caching support for AJAX libraries (including jQuery and ASP.NET AJAX) and are composed of “edge cache” servers, they are strategically placed around the world to make sure your application will use the nearest server to get the ASP.NET AJAX scripts, isn’t that cool?! The service is free and both for commercial and non-commercial purpose. To get a JavaScript from the Microsoft CDN, you can simply use the &amp;lt;script&amp;gt; tag to include the script from &lt;A href="http://ajax.microsoft.com/ajax" mce_href="http://ajax.microsoft.com/ajax"&gt;”http://ajax.microsoft.com/ajax&lt;/A&gt;”. Microsoft CND will use sub folders to versioning the different kind of scripts. The ASP.NET AJAX 4.0 Preview 5.0 script can be found under the /0909/ folder (the name of the folder represents the year and month when the ASP.NET AJAX was released). You can find the JavaScript and URLs here: &lt;A title=http://www.asp.net/ajax/cdn/ href="http://www.asp.net/ajax/cdn/" mce_href="http://www.asp.net/ajax/cdn/"&gt;http://www.asp.net/ajax/cdn/&lt;/A&gt; &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;Note: ScriptManger can automatically request JavaScript files form the Microsoft CDN if the EnableCdn property of the ScriptManager is set to true.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;I have used the following code to include the ASP.NET AJAX 4.0 Preview 5.0 script in my demo, to make sure I can use Templates, and ADO.NET DataServices: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=html&gt;&amp;lt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjax.js"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjaxTemplates.js"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&amp;lt;script src=&lt;SPAN class=str&gt;"http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjaxAdoNet.js"&lt;/SPAN&gt; type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjaxDataContext.js"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;To use the ADO.NET Data Service (RentalWebDataSerivce) on the client-side, the ASP.NET AJAX $create shortcut can be used to create a ADO.Net DataContext object, the DataContex is the proxy class to access the ADO.Net Data Service: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; RentalService = {};

RentalService.dataContext = $create(Sys.Data.AdoNetDataContext,
                                         {
                                             serviceUri: &lt;SPAN class=str&gt;"RentalWebDataService.svc"&lt;/SPAN&gt;,
                                             mergeOption: Sys.Data.MergeOption.appendOnly
                                         });&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;The following is the template I have used to list the cars: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt; &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;table&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:attach&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="dataview"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sys-template"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;dataview:dataprovider&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ RentalService.dataContext }}"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;dataview:fetchoperation&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Rental"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;dataview:autofetch&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="true"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;

        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:if&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="$index==0"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;Booking No&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;Description&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        
         &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:style-background-color&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{binding Status, convert=convertStatusToColor, ColorType=Name}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
             &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;{{ ID }}&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
             &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;{{ Description }}&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
         &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;table&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;Yes, I know, I use a table instead of a DIV, shame on me..&lt;/P&gt;
&lt;P&gt;To create a template the class=”sys-template” must be applied to the root element of the template, the sys:attached=”dataview” will indicate that I will use the ASP.NET AJAX 4.0 DataView features together with the template. To make sure the DataView will get its data from the RentalWebDataService, the dataview:dataprovider attribute is used and its value is set to the RentalService.dataContext object, the DataView’s autofecth property is also set to true, to automatically fetch data. The fetchoperation property will specify which operation of the RentalWebDataServices should be used when the DataView fetches the data.&lt;/P&gt;
&lt;P&gt;There are two ways to bind data within a template, for example the short {{ field }} expression or the {binding field} expression. As you can see I have used both expressions in the template, one for the background-color style (to bind a value to a specific style attribute, the sys:style-&amp;lt;style&amp;gt; attribute is used). The {{ ID }} and {{ Description }} shortcut will make sure to get the data from the Rental’s (The entity returned from the Rental operation of the RentalWebDataService ) ID and Description property. Take a look at the binding expression used for the &amp;lt;tr&amp;gt; background-color style: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:style-background-color&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{binding Status, convert=convertStatusToColor, ColorType=Name}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;There is now an option to specify a Converter, a method which will take the bounded value and pass it as an argument to the specified method and do a conversion and return a new whole value. The Status property in my case returns a string with different kind of status, Approved, NotApproved and Pending. What I want to do, is to convert those values into different colors as I mention earlier in my post. To do that I have used the new Converter feature. To set up a converter is easy just use the Sys.Binding.converters property and assign a method to it with two arguments, the value to convert and a binding argument (holds information about the binding). &lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;Sys.Binding.converters.convertStatusToColor = &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt;(status, binding)
{
     &lt;SPAN class=rem&gt;//do something then return the converted value&lt;/SPAN&gt;
}&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;One great thing with the converter, is the possibility to use expandos, for example in my code I have added a ColorType expando to specify if the color that returned from the converter should be a name or not. The binding argument of the converter method can be used to get the expando, for example:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=str&gt;"{binding Status, convert=convertStatusToColor, ColorType=Name}"&lt;/SPAN&gt;


Sys.Binding.converters.convertStatusToColor = function(status, binding)
{
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( binding.ColorName == &lt;SPAN class=str&gt;'Name'&lt;/SPAN&gt;)
          &lt;SPAN class=rem&gt;//....&lt;/SPAN&gt;
     &lt;SPAN class=rem&gt;//do something then return the converted value&lt;/SPAN&gt;
}&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;I have created the ugliest converter method ever made, here it is: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;Sys.Binding.converters.convertStatusToColor = &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt;(status, binding)
{
       &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (binding.ColorType == &lt;SPAN class=str&gt;'Name'&lt;/SPAN&gt;)
      {
             &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;'Approved'&lt;/SPAN&gt;)
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'green'&lt;/SPAN&gt;;
                &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;'NotApproved'&lt;/SPAN&gt;)
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'red'&lt;/SPAN&gt;;
                &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;'Pending'&lt;/SPAN&gt;)
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'yellow'&lt;/SPAN&gt;;
                &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'white'&lt;/SPAN&gt;;
        }
        &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;
       {
             &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;"Approved"&lt;/SPAN&gt;)
                 &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'#00ff00'&lt;/SPAN&gt;;
             &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;"NotApproved"&lt;/SPAN&gt;)
                 &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'#ff0000'&lt;/SPAN&gt;;
             &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;'Pending'&lt;/SPAN&gt;)
                 &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'#ffff00'&lt;/SPAN&gt;;
             &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;
                 &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'#ffffff'&lt;/SPAN&gt;;
        }
}&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;Well, it’s a simple method to convert the incoming string, and return a color for the &amp;lt;tr&amp;gt;’s background-color. Here is the whole client-side code: &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=asp&gt;&amp;lt;%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %&amp;gt;&lt;/SPAN&gt;

&lt;SPAN class=kwrd&gt;&amp;lt;!&lt;/SPAN&gt;&lt;SPAN class=html&gt;DOCTYPE&lt;/SPAN&gt; &lt;SPAN class=attr&gt;html&lt;/SPAN&gt; &lt;SPAN class=attr&gt;PUBLIC&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;

&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;html&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://www.w3.org/1999/xhtml"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;head&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;title&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;title&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjax.js"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
    &amp;lt;script src=&lt;SPAN class=str&gt;"http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjaxTemplates.js"&lt;/SPAN&gt; type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script src=&lt;SPAN class=str&gt;"http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjaxAdoNet.js"&lt;/SPAN&gt; type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script src=&lt;SPAN class=str&gt;"http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjaxDataContext.js"&lt;/SPAN&gt; type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;&amp;lt;/script&amp;gt;


    &amp;lt;script type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;

        &lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; RentalService = {};

        RentalService.dataContext = $create(Sys.Data.AdoNetDataContext,
                                         {
                                             serviceUri: &lt;SPAN class=str&gt;"RentalWebDataService.svc"&lt;/SPAN&gt;,
                                             mergeOption: Sys.Data.MergeOption.appendOnly
                                         });


        Sys.Binding.converters.convertStatusToColor = &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt;(status, binding) {

            &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (binding.ColorType == &lt;SPAN class=str&gt;'Name'&lt;/SPAN&gt;) {

                &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;'Approved'&lt;/SPAN&gt;)
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'green'&lt;/SPAN&gt;;
                &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;'NotApproved'&lt;/SPAN&gt;)
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'red'&lt;/SPAN&gt;;
                &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;'Pending'&lt;/SPAN&gt;)
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'yellow'&lt;/SPAN&gt;;
                &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'white'&lt;/SPAN&gt;;
            }
            &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt; {
                &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;"Approved"&lt;/SPAN&gt;)
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'#00ff00'&lt;/SPAN&gt;;
                &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;"NotApproved"&lt;/SPAN&gt;)
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'#ff0000'&lt;/SPAN&gt;;
                &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (status == &lt;SPAN class=str&gt;'Pending'&lt;/SPAN&gt;)
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'#ffff00'&lt;/SPAN&gt;;
                &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;
                    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;'#ffffff'&lt;/SPAN&gt;;
            }
        }

    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;style&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/css"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        .sys-template { display:none; }
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;style&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;

&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;head&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns:sys&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns:dataview&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys.UI.DataView"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;table&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:attach&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="dataview"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sys-template"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;dataview:dataprovider&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ RentalService.dataContext }}"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;dataview:fetchoperation&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Rental"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;dataview:autofetch&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="true"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;

        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:if&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="$index==0"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;Booking No&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;Description&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        
         &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:style-background-color&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{binding Status, convert=convertStatusToColor, ColorType=Name}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
             &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;{{ ID }}&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
             &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;{{ Description }}&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;td&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
         &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;table&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;html&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;&lt;STRONG&gt;Summary&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In this blog post you have seen how to data bind and use the DataView to do client-side binding to a ADO.NET Data Service, you have also got introduced to the Microsoft AJAX NDC, if you want to get more information about the NDC, check out Scott Guthrie's blog: &lt;A title=http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx" mce_href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx&lt;/A&gt;, you have also seen the new Preview 5 converter feature.&lt;/P&gt;
&lt;P&gt;To find more information about ASP.NET AJAX 4.0 Preview 5.0, you can check out my two earlier posts:&lt;/P&gt;
&lt;P&gt;&lt;A title=http://weblogs.asp.net/fredriknormen/archive/2009/09/11/asp-net-ajax-4-0-preview-5-available.aspx href="http://weblogs.asp.net/fredriknormen/archive/2009/09/11/asp-net-ajax-4-0-preview-5-available.aspx" mce_href="http://weblogs.asp.net/fredriknormen/archive/2009/09/11/asp-net-ajax-4-0-preview-5-available.aspx"&gt;http://weblogs.asp.net/fredriknormen/archive/2009/09/11/asp-net-ajax-4-0-preview-5-available.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A title=http://weblogs.asp.net/fredriknormen/archive/2009/09/11/keep-the-first-empty-item-in-a-listbox-when-using-asp-net-ajax-4-0-preview-5-and-observer.aspx href="http://weblogs.asp.net/fredriknormen/archive/2009/09/11/keep-the-first-empty-item-in-a-listbox-when-using-asp-net-ajax-4-0-preview-5-and-observer.aspx" mce_href="http://weblogs.asp.net/fredriknormen/archive/2009/09/11/keep-the-first-empty-item-in-a-listbox-when-using-asp-net-ajax-4-0-preview-5-and-observer.aspx"&gt;http://weblogs.asp.net/fredriknormen/archive/2009/09/11/keep-the-first-empty-item-in-a-listbox-when-using-asp-net-ajax-4-0-preview-5-and-observer.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Jim, Dave and Bertrand Le Roy’s posts on Preview 5: &lt;BR&gt;&lt;A href="http://weblogs.asp.net/jimwang/archive/2009/09/11/asp-net-ajax-preview-5-and-updatepanel.aspx" mce_href="http://weblogs.asp.net/jimwang/archive/2009/09/11/asp-net-ajax-preview-5-and-updatepanel.aspx"&gt;http://weblogs.asp.net/jimwang/archive/2009/09/11/asp-net-ajax-preview-5-and-updatepanel.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/infinitiesloop/archive/2009/09/10/microsoft-ajax-4-preview-5-the-dataview-control.aspx" mce_href="http://weblogs.asp.net/infinitiesloop/archive/2009/09/10/microsoft-ajax-4-preview-5-the-dataview-control.aspx"&gt;http://weblogs.asp.net/infinitiesloop/archive/2009/09/10/microsoft-ajax-4-preview-5-the-dataview-control.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&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" mce_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 mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7208540" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/AXAJ/default.aspx">AXAJ</category><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/CDN/default.aspx">CDN</category><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/ASP.NET+AJAX/default.aspx">ASP.NET AJAX</category></item><item><title>Keep the first “empty” Item in a listbox when using ASP.NET AJAX 4.0 Preview 5 and Observer</title><link>http://weblogs.asp.net/fredriknormen/archive/2009/09/11/keep-the-first-empty-item-in-a-listbox-when-using-asp-net-ajax-4-0-preview-5-and-observer.aspx</link><pubDate>Fri, 11 Sep 2009 15:09:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7200984</guid><dc:creator>Fredrik N</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/fredriknormen/rsscomments.aspx?PostID=7200984</wfw:commentRss><comments>http://weblogs.asp.net/fredriknormen/archive/2009/09/11/keep-the-first-empty-item-in-a-listbox-when-using-asp-net-ajax-4-0-preview-5-and-observer.aspx#comments</comments><description>&lt;P&gt;I got a question as a comment on my &lt;A href="http://weblogs.asp.net/fredriknormen/archive/2009/09/11/asp-net-ajax-4-0-preview-5-available.aspx" mce_href="http://weblogs.asp.net/fredriknormen/archive/2009/09/11/asp-net-ajax-4-0-preview-5-available.aspx"&gt;previous post about the new features and changes to ASP.NET AJAX 4.0 Preview 5&lt;/A&gt;. I hope I understood the question right ;) It was about using a listbox and add an empty item at the top of the list, and keep it there when adding new items to an array that is bounded to the list, and by using the Observer feature. Maybe some more have or will have the same question, so I decided to write a blog post about it.&lt;/P&gt;
&lt;P&gt;In this blog post I will use a sys-template for the listbox, here is an example of a listbox template by using HTML &amp;lt;select&amp;gt; element:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&lt;BR&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;select&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:attach&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="dataview"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sys-template"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;dataview:data&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ customers }}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;option&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ID}}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;{{ Name }}&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;/option&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;select&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR&gt;I will in this example use the dataview feature to simply fill the Listbox with values form an array.&lt;/P&gt;
&lt;P&gt;If we want to use ASP.NET AJAX 4.0 and the dataview feature, we need to add the sys and dataview namespace to the &amp;lt;body&amp;gt; tag:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&lt;BR&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:sys&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys"&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:dataview&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys.UI.DataView"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;&lt;STRONG&gt;&lt;EM&gt;Note: We don’t need to add the sys:activate=”*” attribute to the &amp;lt;body&amp;gt; element anymore.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;I will in this post use a simple hard coded javascript array for the customers bounded to the listbos, and here is my simple array together with a AddCustomer method: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; customers = [
                      { ID : &lt;SPAN class=str&gt;"JD"&lt;/SPAN&gt;, Name : &lt;SPAN class=str&gt;"John Doe"&lt;/SPAN&gt; },
                      { ID : &lt;SPAN class=str&gt;"JD2"&lt;/SPAN&gt;, Name : &lt;SPAN class=str&gt;"Jane Doe"&lt;/SPAN&gt;}
                    ];
&lt;BR&gt;&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt; AddCustomer()
    {
        Sys.Observer.add(customers, { ID: &lt;SPAN class=str&gt;"JD2"&lt;/SPAN&gt;, Name: &lt;SPAN class=str&gt;"Some Doe"&lt;/SPAN&gt; });
    }
    
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;
The AddCustomer method will make sure to add a new customer to the customers array. The Sys.Observer is used to make sure the listbox which is bound to the customers array should be updated automatically when a new customer is added to the customers array.&lt;/P&gt;
&lt;P&gt;Here is the code for the whole solution so far: &lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;html&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://www.w3.org/1999/xhtml"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;head&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;title&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;title&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Scripts/MicrosoftAjax.debug.js"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &amp;lt;script type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt; src=&lt;SPAN class=str&gt;"Scripts/MicrosoftAjaxTemplates.debug.js"&lt;/SPAN&gt;&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;

        &lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; customers = [
                            { ID : &lt;SPAN class=str&gt;"JD"&lt;/SPAN&gt;, Name : &lt;SPAN class=str&gt;"John Doe"&lt;/SPAN&gt; },
                            { ID : &lt;SPAN class=str&gt;"JD2"&lt;/SPAN&gt;, Name : &lt;SPAN class=str&gt;"Jane Doe"&lt;/SPAN&gt;}
                        ];

        &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt; AddCustomer()
        {
            Sys.Observer.add(customers, { ID: &lt;SPAN class=str&gt;"JD2"&lt;/SPAN&gt;, Name: &lt;SPAN class=str&gt;"Some Doe"&lt;/SPAN&gt; });
        }
    
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;style&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/css"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
        .sys-template { display:none; }
    
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;style&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;head&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;

&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:sys&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys"&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:dataview&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys.UI.DataView"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;form&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="form1"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;select&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:attach&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="dataview"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sys-template"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;dataview:data&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ customers }}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;option&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ID}}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;{{ Name }}&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;/option&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;select&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
   &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="button"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;onclick&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="AddCustomer();"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Add item"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
   
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;form&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;html&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;As you may already notice there is no empty item at the top of the listbox items. So we add one to the template:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;BR&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;select&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:attach&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="dataview"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sys-template"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;dataview:data&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ customers }}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;option value=””&lt;/SPAN&gt; &lt;SPAN class=attr&gt;selected&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="selected"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;Select an Item&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;/option&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;option&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ID}}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;{{ Name }}&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;/option&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;select&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;If we run the code, we will notice that several “Select an Item” will be added to the listbox. What we want to do is to keep the first and “empty” item when a new customer is added to the customers array, we don’t want to have the “empty” list repeatable for each item in the list. To solve this we can use the sys:if attribute. We simply use it to see if the index of the currently bounded item is 0, if so, we add the “empty” item. By doing that we will make sure to only have one “empty” item added, and it will only&amp;nbsp; be added when the index is 0. &lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;select&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:attach&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="dataview"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sys-template"&lt;/SPAN&gt;
        &lt;SPAN class=attr&gt;dataview:data&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ customers }}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
            &lt;STRONG&gt;&lt;EM&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;option&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:if&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="$index==0"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;=""&lt;/SPAN&gt; &lt;SPAN class=attr&gt;selected&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="selected"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;Select an Item&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;/option&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt;
            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;option&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ID}}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;{{ Name }}&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;/option&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;select&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;I hope this post may be useful for some of you, but I will be so happy to see more Silverlight developers ;)&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7200984" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/AXAJ/default.aspx">AXAJ</category></item><item><title>ASP.NET AJAX 4.0 Preview 5 available</title><link>http://weblogs.asp.net/fredriknormen/archive/2009/09/11/asp-net-ajax-4-0-preview-5-available.aspx</link><pubDate>Fri, 11 Sep 2009 07:39:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7200439</guid><dc:creator>Fredrik N</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/fredriknormen/rsscomments.aspx?PostID=7200439</wfw:commentRss><comments>http://weblogs.asp.net/fredriknormen/archive/2009/09/11/asp-net-ajax-4-0-preview-5-available.aspx#comments</comments><description>&lt;P&gt;Microsoft have recently released the Preview 5 of ASP.NET AJAX 4.0 on &lt;A href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=32770" mce_href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=32770"&gt;CodePlex&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;In Preview 5 of ASP.NET AJAX 4.0 you can see some improvements to the lient-side data story introduced in previous previews of ASP.NET AJAX. In this release, Microsoft have add support for the following features: 
&lt;P&gt;&lt;BR&gt;Dynamic and recursive templates &lt;/P&gt;
&lt;P&gt;Binding Converters&lt;/P&gt;
&lt;P&gt;UpdatePanel support&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some changes made from Preview 4 to 5&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR&gt;Declarative Attribute Changes&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;There is no need to include the sys:active attribute on the &amp;lt;body&amp;gt; element of a page containing declarative markup.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&lt;BR&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:sys&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys"&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:dataview&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys.UI.DataView"&lt;/SPAN&gt;
    &lt;STRIKE&gt;&lt;SPAN class=attr&gt;sys:activate&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="*"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/STRIKE&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;When binding to attributes before we could write something like this:&lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;ul&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:attach&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="dataview"&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sys-template"&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;dataview:data&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{ imagesArray }}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;li&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;h3&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;{{ Name }}&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;h3&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;{{ Description }}&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{Name}}"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;li&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;ul&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;Now all attributes that contain the {{..}} or {binding ..} must now use the “sys” prefix:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&lt;BR&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text"&lt;/SPAN&gt; &lt;STRONG&gt;sys:&lt;/STRONG&gt;&lt;SPAN class=attr&gt;value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{{Name}}"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P&gt;Some changes has also been made to the “code” and “class” attributes, they are moved to into “Sys”&lt;BR&gt;&lt;BR&gt;code:if -&amp;gt; sys:if&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&lt;BR&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;thead&lt;/SPAN&gt; &lt;SPAN class=attr&gt;&lt;STRIKE&gt;code:if&lt;/STRIKE&gt;&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&lt;STRIKE&gt;="$index==0"&lt;/STRIKE&gt; &lt;SPAN class=attr&gt;sys:if&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="$index==0"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;th&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;Image&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;th&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;th&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;Description&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;th&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
 &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;tr&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;thead&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P&gt;code:before -&amp;gt; sys:codebefore&lt;BR&gt;code:after -&amp;gt; sys:codeafter&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;The ‘class’ attributes have been moved into ‘sys’.&lt;BR&gt;&lt;BR&gt;class:foo -&amp;gt; sys:class-foo&lt;BR&gt;&lt;BR&gt;The ‘style’ attributes have been moved into ‘sys’.&lt;BR&gt;&lt;BR&gt;style:font-size=”8” -&amp;gt; sys:style-font-size=”8”&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Top Level Binding&lt;BR&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In the previous version of ASP.NET AJAX 4.0, we could only use binding by using a template marked with sys-template, we can now instead use the&amp;nbsp; &lt;STRONG&gt;sys:value=”{binding &lt;EM&gt;field&lt;/EM&gt;, source={{&lt;EM&gt;source&lt;/EM&gt;}}}”&lt;/STRONG&gt;&amp;nbsp; attribute, for example:&lt;/P&gt;&lt;SPAN class=kwrd&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&lt;BR&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;html&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://www.w3.org/1999/xhtml"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;head&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;title&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;title&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Scripts/MicrosoftAjax.debug.js"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &amp;lt;script type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt; src=&lt;SPAN class=str&gt;"Scripts/MicrosoftAjaxTemplates.debug.js"&lt;/SPAN&gt;&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;

        &lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; customer = { Name : &lt;SPAN class=str&gt;"John Doe"&lt;/SPAN&gt; };
    
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;head&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;

&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns:sys&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;form&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="form1"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;

         &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{binding Name,source={{customer}} }"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;form&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;html&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;
&lt;PRE class=csharpcode&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;If we have two input field which is bound to the same source, for example&lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{binding Name, source={{customer}}}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Text1"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{binding Name, source={{customer}}}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;and we change the value of field “Text1”, the value of “text” will be automatically changed.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;We can also use the Sys.Observer to update the binding value:&lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;html&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://www.w3.org/1999/xhtml"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;head&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;title&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;title&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Scripts/MicrosoftAjax.debug.js"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &amp;lt;script type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt; src=&lt;SPAN class=str&gt;"Scripts/MicrosoftAjaxTemplates.debug.js"&lt;/SPAN&gt;&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;

        &lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; customer = { Name: &lt;SPAN class=str&gt;"John Doe"&lt;/SPAN&gt; };
        
        &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt; clickMe()
        {
            &lt;SPAN class=rem&gt;//Will not update the fields&lt;/SPAN&gt;
            customer.Name = &lt;SPAN class=str&gt;"Hej"&lt;/SPAN&gt;;

            &lt;SPAN class=rem&gt;//Will update the fields&lt;/SPAN&gt;
            Sys.Observer.setValue(customer, &lt;SPAN class=str&gt;"Name"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"Jane Doe"&lt;/SPAN&gt;);
        }
    
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;head&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;

&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt;   &lt;SPAN class=attr&gt;xmlns:sys&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;form&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="form1"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="myTemplate"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{binding Name, source={{customer}}}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Text1"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{binding Name, source={{customer}}}"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="button"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;onclick&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="clickMe()"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Click Me"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="form"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;form&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;html&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Binding Converters and Expandos&lt;BR&gt;&lt;/STRONG&gt;&lt;BR&gt;Bindings now support converters by using the Sys.Binding.converters field.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;{ binding foo,convert=myconverter }&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;BR&gt;Note: There are no Converters out of the box&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Here is an example:&lt;BR&gt;&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;html&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://www.w3.org/1999/xhtml"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;head&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;title&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;title&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Scripts/MicrosoftAjax.debug.js"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &amp;lt;script type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt; src=&lt;SPAN class=str&gt;"Scripts/MicrosoftAjaxTemplates.debug.js"&lt;/SPAN&gt;&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script type=&lt;SPAN class=str&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;

        &lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; customer = { Name: &lt;SPAN class=str&gt;"John Doe"&lt;/SPAN&gt;, Age : 31 };
        
        Sys.Binding.converters.myconverter = &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt;(valueToConvert, binding) {
            &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (valueToConvert &amp;gt;= 18)
                &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;"checked"&lt;/SPAN&gt;;
            &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt;
                &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=str&gt;""&lt;/SPAN&gt;;
        }
    
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;style&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/css"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
        .sys-template { display:none; }
    
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;style&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;head&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;

&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:sys&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys"&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:dataview&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="javascript:Sys.UI.DataView"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;form&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="form1"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;input&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="isAdult"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="checkbox"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:checked&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{binding Age, source={{customer}}, &lt;STRONG&gt;convert=myconverter}&lt;/STRONG&gt;"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;form&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;body&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;html&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We can also set expandos, for example:&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;{binding foo,convert=format,format=MM/dd} &lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Sys.Binding.converters.format = function(value, binding) {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // binding.format === MM/dd&lt;BR&gt;} 
&lt;P&gt;&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Binding Updates&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;We can now use the sys:innettext and sys:innerhtml to make sure it will show us the HTML code in the browser or as pure HTML. For example if we have a variable “foo” and withthe value “&amp;lt;p&amp;gt;Silverligth Rocks!&amp;lt;/p&amp;gt;”, we maybe want it to be displayed as normal text in the browser, if that is the case we can use sys:innettext:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&lt;BR&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:innertext&lt;/SPAN&gt;=”{{ &lt;SPAN class=attr&gt;foo&lt;/SPAN&gt; }}”&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P&gt;&lt;BR&gt;If we want it to result as a normal HTML we can instead use the innerhtml:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&lt;BR&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt; &lt;SPAN class=attr&gt;sys:innerhtml&lt;/SPAN&gt;=”{{ &lt;SPAN class=attr&gt;foo&lt;/SPAN&gt; }}”&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Compatibility with the ASP.NET UpdatePanel&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Preview 4 of the ASP.NET AJAX 4.0 didn’t support UpdatePanel in ASP.NET 3.5. But in the preview 5 will now work with either 3.5 or 4.0 on the server. To make sure the Preview 5 should work with an UpdatePanel, you need to replace the partial rendering script MicrosoftAjaxWebForms.js wtih the 4.0 version.&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptManager&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;=”&lt;SPAN class=attr&gt;server&lt;/SPAN&gt;”&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Scripts&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptReference&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Name&lt;/SPAN&gt;=”&lt;SPAN class=attr&gt;MicrosoftAjax&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;js&lt;/SPAN&gt;” &lt;SPAN class=attr&gt;Path&lt;/SPAN&gt;=”~/&lt;SPAN class=attr&gt;scripts&lt;/SPAN&gt;/&lt;SPAN class=attr&gt;MicrosoftAjax&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;js&lt;/SPAN&gt;” &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptReference&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Name&lt;/SPAN&gt;=”&lt;SPAN class=attr&gt;MicrosoftAjaxWebForms&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;js&lt;/SPAN&gt;” &lt;SPAN class=attr&gt;Path&lt;/SPAN&gt;=”~/&lt;SPAN class=attr&gt;scripts&lt;/SPAN&gt;/&lt;SPAN class=attr&gt;MicrosoftAjaxWebForms&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;js&lt;/SPAN&gt;” &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Scripts&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptManager&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;/PRE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Supported Browsers&lt;BR&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The ASP.NET AJAX 4.0 Preview 5 is tested on the following browsers (I know a lot of people are asking this kind of questions ;))&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;Microsoft Internet Explorer 6 
&lt;P&gt;Microsoft Internet Explorer 7 
&lt;P&gt;Microsoft Internet Explorer 8 RC1 
&lt;P&gt;Mozilla Firefox 3 and 3.5 
&lt;P&gt;Apple Safari 4 
&lt;P&gt;Opera 10 
&lt;P&gt;Chrome 2 
&lt;P&gt;&lt;STRONG&gt;How to use the ASP.NET AJAX 4.0 Preview 5 in your applications&lt;/STRONG&gt; 
&lt;P&gt;&lt;BR&gt;If we want to use the ASP.NET AJAX 4.0 Preview 5, we need to reference to the new script files, we can do this by using the &amp;lt;script&amp;gt; tag or adding ScriptReferernces to the ScriptManager control:&lt;BR&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptManager&lt;/SPAN&gt; &lt;SPAN class=attr&gt;ID&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sm"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runat&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="server"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Scripts&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptReference&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="MicrosoftAjax.js"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Path&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="~/scripts/MicrosoftAjax.js"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptReference&lt;/SPAN&gt; &lt;SPAN class=attr&gt;ScriptMode&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Inherit"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Path&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="~/scripts/MicrosoftAjaxTemplates.js"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptReference&lt;/SPAN&gt; &lt;SPAN class=attr&gt;ScriptMode&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Inherit"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Path&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="~/scripts/MicrosoftAjaxAdoNet.js"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptReference&lt;/SPAN&gt; &lt;SPAN class=attr&gt;ScriptMode&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Inherit"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Path&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="~/scripts/MicrosoftAjaxDataContext.js"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Scripts&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;asp:ScriptManager&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;BR&gt;&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;Example using &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; tags:
&lt;/PRE&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="../scripts/MicrosoftAjax.debug.js"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="../scripts/MicrosoftAjaxTemplates.debug.js"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="../scripts/MicrosoftAjaxAdoNet.debug.js"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="../scripts/MicrosoftAjaxDataContext.debug.js"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/STYLE&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7200439" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/AXAJ/default.aspx">AXAJ</category></item><item><title>ASP.NET MVC Framework - Ajax</title><link>http://weblogs.asp.net/fredriknormen/archive/2007/11/26/asp-net-mvc-framework-ajax.aspx</link><pubDate>Mon, 26 Nov 2007 16:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5342176</guid><dc:creator>Fredrik N</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/fredriknormen/rsscomments.aspx?PostID=5342176</wfw:commentRss><comments>http://weblogs.asp.net/fredriknormen/archive/2007/11/26/asp-net-mvc-framework-ajax.aspx#comments</comments><description>&lt;P mce_keep="true"&gt;Take look at Nikhil's blog about how AJAX can be used with the ASP.Net MVC Framework:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;A href="http://www.nikhilk.net/Ajax-MVC.aspx"&gt;http://www.nikhilk.net/Ajax-MVC.aspx&lt;/A&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5342176" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/MVC+Framework/default.aspx">MVC Framework</category><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/ASP.Net/default.aspx">ASP.Net</category><category domain="http://weblogs.asp.net/fredriknormen/archive/tags/AXAJ/default.aspx">AXAJ</category></item></channel></rss>