<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andrey Shchekin &#187; DataBinding</title>
	<atom:link href="http://blog.ashmind.com/category/databinding/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ashmind.com</link>
	<description></description>
	<lastBuildDate>Mon, 15 Mar 2010 18:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Some thoughts on ASP.NET AJAX Roadmap</title>
		<link>http://blog.ashmind.com/2008/07/19/some-thoughts-on-aspnet-ajax-roadmap/</link>
		<comments>http://blog.ashmind.com/2008/07/19/some-thoughts-on-aspnet-ajax-roadmap/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 15:59:48 +0000</pubDate>
		<dc:creator>Andrey Shchekin</dc:creator>
				<category><![CDATA[ASP.NET AJAX]]></category>
		<category><![CDATA[DataBinding]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.ashmind.com/index.php/2008/07/19/some-thoughts-on-aspnet-ajax-roadmap/</guid>
		<description><![CDATA[Coming from a vacation, I have just discovered a new ASP.NET AJAX roadmap. A post by Matt Berseth starts with a summary of discussion done so far. I have some personal opinions on the question of ASP.NET AJAX since our team worked with it a lot. So I decided to write a post instead of [...]]]></description>
			<content:encoded><![CDATA[<p>Coming from a vacation, I have just discovered a new <a href="http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14924">ASP.NET AJAX roadmap</a>. <a href="http://mattberseth.com/blog/2008/07/my_feedback_aspnet_ajax_roadma.html">A post</a> by <a href="http://mattberseth.com/">Matt Berseth</a> starts with a summary of discussion done so far.</p>
<p>I have some personal opinions on the question of ASP.NET AJAX since our team worked with it a lot. So I decided to write a post instead of just commenting existing discussion.</p>
<p>I think I have a slightly different approach to this framework, as compared to other posters. I do not have to choose jQuery/prototype/mootools over ASP.NET AJAX. It is obvious that chaining in jQuery makes life easier, and extending element whenever possible is also a friendly approach.</p>
<p>However, I will still use ASP.NET AJAX for the interoperability with ASP.NET architecture &#8212; I can have a JavaScript part for any control I have, and pass values between C# and JavaScript. Also the component lifecycle (being able to handle component references easily) is a large win for me.</p>
<p>What I do not like is the cumbersome get_/set_ requirement without a built-in shortcut (I <a href="http://blog.ashmind.com/index.php/2007/10/08/metaprogramming-in-javascript-auto-properties-for-aspnet-ajax/">described</a> one solution earlier) and cumbersome event subscription.</p>
<h4>Event Subscription</h4>
<p>So, let&#8217;s start with this roadmap sample:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>$query(<span class="str">"textarea.rich"</span>)</pre>
<pre><span class="lnum">   2:  </span>  .addHandler(<span class="str">"focus"</span>, <span class="kwrd">function</span>(e) {</pre>
<pre class="alt"><span class="lnum">   3:  </span>    Sys.Debug.trace(<span class="str">"focused into "</span> + (e.eventTarget.id || <span class="str">"?"</span>));</pre>
<pre><span class="lnum">   4:  </span>  })</pre>
<pre class="alt"><span class="lnum">   5:  </span>  .setStyle(<span class="str">"width"</span>, <span class="kwrd">function</span>() {</pre>
<pre><span class="lnum">   6:  </span>    <span class="kwrd">return</span> (document.body.clientWidth – 10) + <span class="str">"px"</span>;</pre>
<pre class="alt"><span class="lnum">   7:  </span>  })</pre>
<pre><span class="lnum">   8:  </span>  .create(Contoso.UI.RichTextBehavior, {</pre>
<pre class="alt"><span class="lnum">   9:  </span>    showToolbar: <span class="kwrd">true</span>,</pre>
<pre><span class="lnum">  10:  </span>    fonts: [<span class="str">"Arial"</span>, <span class="str">"Times"</span>, <span class="str">"Courier"</span>]</pre>
<pre class="alt"><span class="lnum">  11:  </span>  });</pre>
</div>
<p>What we have now in our project for event subscription is similar to this</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>with (Auto.Events) {</pre>
<pre><span class="lnum">   2:  </span>  when(textarea).gets(<span class="str">'focus'</span>).call(<span class="str">'textarea_got_focus'</span>).on(<span class="kwrd">this</span>);</pre>
<pre class="alt"><span class="lnum">   3:  </span>  when(list).has(<span class="str">'changed'</span>).call(<span class="kwrd">function</span>() { alert(<span class="str">'list_changed'</span>); })</pre>
<pre><span class="lnum">   4:  </span>}</pre>
</div>
<style type="text/css">.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; }
</style>
<p>
Which also alters dispose to remove the event handler (which is something very tedious to do manually).</p>
<p>So the thing I most dislike in new ASP.NET AJAX syntax is that it is not readable (just plain chaining). I see <a href="http://livepipe.net/extra/event_behavior">Event.Behavior</a> as a beautiful solution, jQuery&#8217;s as acceptable one (not a language, just more precise naming shortcuts), and ASP.NET AJAX as not really usable.</p>
<p>Same goes to $listen &#8212; I just can not remember the correct order of arguments unless looking directly to the documentation or IntelliSense. </p>
<p>But I think that $listen is a great idea, and the solution should be very interesting (considering that IE does not support <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-mutationevents">DOM mutation events</a>).</p>
<h4>Templates</h4>
<p>Most popular post in my blog is about <a href="http://blog.ashmind.com/index.php/2007/06/21/client-side-databinding-with-aspnet-ajax-futures/">client-side databinding</a>. I can not show a solution that we have built to solve this issue (we have built it specifically for a project which sources I can not show), so this post is somewhat useless.</p>
<p>I am very hopeful about ASP.NET AJAX&#8217;s UI Templates, but I am also thinking about several problems we encountered.&nbsp; The first one is performance &#8212; it is absolutely necessary to pre-cache template binding function. The second one is binding repeated template with server controls.</p>
<p>There is a sample in the roadmap document:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="rem">&lt;!--* for (var i = 0; i &lt; features.length; i++) { *--&gt;</span></pre>
<pre><span class="lnum">   2:  </span>  <span class="kwrd">&lt;</span><span class="html">span</span><span class="kwrd">&gt;</span>{{ features[i].name }}<span class="kwrd">&lt;/</span><span class="html">span</span><span class="kwrd">&gt;</span></pre>
<pre class="alt"><span class="lnum">   3:  </span>  <span class="rem">&lt;!--* </span></pre>
<pre><span class="lnum">   4:  </span><span class="rem">    $create(Contoso.Tooltip, {</span></pre>
<pre class="alt"><span class="lnum">   5:  </span><span class="rem">      text: features[i].description</span></pre>
<pre><span class="lnum">   6:  </span><span class="rem">    }, {}, {}, $element);</span></pre>
<pre class="alt"><span class="lnum">   7:  </span><span class="rem">  *--&gt;</span></pre>
<pre><span class="lnum">   8:  </span><span class="rem">&lt;!--* } *--&gt;</span></pre>
</div>
<p>but I am not sure if it is possible to do this:</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="rem">&lt;!--* for (var i = 0; i &lt; features.length; i++) { *--&gt;</span></pre>
<pre><span class="lnum">   2:  </span>  <span class="kwrd">&lt;</span><span class="html">my:Label</span> <span class="attr">Text</span><span class="kwrd">="{{ features[i].name }}"</span> <span class="kwrd">/&gt;</span></pre>
<pre class="alt"><span class="lnum">   3:  </span><span class="rem">&lt;!--* } *--&gt;</span></pre>
</div>
<p>where my:Label is a ASP.NET AJAX control. It was one the most complex problem for our client:Repeater, so I am interested if this would be implemented.</p>
<p>Now, in contrary to Matt Berseth, I am not really concerned with INotifyPropertyChanged, because it is extremely easy to write a meta-helper to auto-implement it for any given object or prototype in JavaScript.</p>
<p>What I <em>am</em> concerned with with is an idea to &#8220;expose methods such as insertRow&#8221; for Client DataSource. I do not have any rows in presentational model or my JavaScript arrays, so I strongly dislike this terminology.</p>
<p>The dream feature for me would be a <a href="http://www.codeplex.com/clinq">Continuous LINQ</a> for JavaScript, where you can dynamically bind to a dynamically filtered collection, bind to products.where(function(p) { return p.Cost &gt; 5; }). We did a basic implementation for this kind of thing, and found it extremely useful for rich web application. You can have a live model behind a complex page, and never explicitly think of updating any part of the page when some collection in the model got changed.</p>
<h4>Animation</h4>
<p>I am not really interested in that &#8212; other frameworks do this kind of thing easier. And if ASP.NET AJAX is going to imitate jQuery syntax, as some people want, why not just use jQuery or mootools?</p>
<h4>Other features</h4>
<p>I think that built-in Drag&amp;Drop may make my life easier, looking forward to it. Also, ASP.NET MVC integration has always been a must, it is nice to see it is coming.</p>
<p>All IDE changes are also very welcome.</p>
<h4>Summary</h4>
<p>In general, I like the proposed changes.</p>
<p>I have a feeling that Microsoft should add more meta helpers as Auto.properties. It is easy to do, but not obvious for the people who are not doing a lot of JavaScript. Also the auto-INotifyPropertyChanged and built-in ObservableCollection would fix databinding cumbersomeness in the same situation.</p>
<p>Also, I am interested in how are the specific technical challenges solved, but it too early to think about that right now.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ashmind.com/2008/07/19/some-thoughts-on-aspnet-ajax-roadmap/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Client-side databinding with ASP.Net AJAX Futures</title>
		<link>http://blog.ashmind.com/2007/06/21/client-side-databinding-with-aspnet-ajax-futures/</link>
		<comments>http://blog.ashmind.com/2007/06/21/client-side-databinding-with-aspnet-ajax-futures/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 22:29:52 +0000</pubDate>
		<dc:creator>Andrey Shchekin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[DataBinding]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.ashmind.com/index.php/2007/06/21/client-side-databinding-with-aspnet-ajax-futures/</guid>
		<description><![CDATA[Recently I got an optimization problem in ASP.Net.To be short, I had a Repeater with custom (somewhat complex) template on my Page, and I wanted to reload it asynchronously. The first solution was XP and didin&#8217;t consider performance at all: wrap Repeater inside an UpdatePanel.The problem was that the entire Page had to be repopulated [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I got an optimization problem in ASP.Net.<br />To be short, I had a Repeater with custom (somewhat complex) template on my Page, and I wanted to reload it asynchronously.</p>
<p>The first solution was XP and didin&#8217;t consider performance at all: wrap Repeater inside an UpdatePanel.<br />The problem was that the entire Page had to be repopulated on server just to get to the Repeater.</p>
<p>That gave me a choice of two headaches: </p>
<ol>
<li>Put all Page/Controls data into ViewState and bloat bandwidth.
<li>Query all additional data on the reload request and increase load on database to get data that will be thrown away. </li>
</ol>
<p>To be honest, I could solve (2) with server-side cache, but, in my opinion, caching does not make ugly solutions any better, just faster. </p>
<p>So, naturally, my thought was to query the data-only WebService and then populate the Repeater on client.</p>
<p>And it was interesting to find out that Microsoft already has a client-side data binding solution within ASP.Net AJAX Futures.<br />I have found an excellent article on this matter by Xianzhong Zhu, &#8220;Unveil the Data Binding Architecture inside Microsoft ASP.NET Ajax 1.0&#8243; (<a href="http://aspalliance.com/1301_Unveil_the_Data_Binding_Architecture_inside_Microsoft_ASPNET_Ajax_10__Part_1">Part 1</a>, <a href="http://aspalliance.com/1301_Unveil_the_Data_Binding_Architecture_inside_Microsoft_ASPNET_Ajax_10__Part_2">Part 2</a>).</p>
<p>I will now&nbsp;give a quick summary on the overall client-side binding architecture.<br />In essence it is quite similar to the smart DataSource controls of ASP.Net 2.0:<br />There is a DataSource javascript component and a ListView javascript control with html template.<br />ListView passes data from/to DataSource control, and DataSource talks with a JSON Web Service as a backend.<br />Controls and their relations&nbsp;are described in <a href="http://www.nikhilk.net/AtlasXMLScript.aspx">text/xml-script</a> (Futures-only feature).</p>
<p>Everything seems quite straightforward and easy to use, I was quite happy to find it.<br />One thing that bothers me is the performance of text/xml-script (it is parsed on client).<br />But it is a concern not related to the current story.<br />The other question is what to do when I want to databind a complex&nbsp;list (consisting of several embedded server user controls) ?<br />I am going to find it out real soon.</p>
<p>Along the way,&nbsp;I have also&nbsp;noticed&nbsp;Sys.Preview.Data also introduces DataSets/DataTables to javascript.<br />That is quite funny.&nbsp;Personally, I&nbsp;never really considered DataSets acceptable anywhere above Persistence layer.<br />But I already thought about Persistence/DataAccess concept in javascript when I saw <a href="http://gears.google.com/">Gears</a>.<br />And DataSets seem to fit &#8216;nicely&#8217; to some&nbsp;GoogleGearsDataSource (it would be quite an experience to actually see one in real code).</p>
<p>Well, javascript O/R Mapper, anyone ?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ashmind.com/2007/06/21/client-side-databinding-with-aspnet-ajax-futures/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

