<?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; ASP.NET AJAX</title>
	<atom:link href="http://blog.ashmind.com/category/net/aspnet/aspnet-ajax/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>Metaprogramming in JavaScript: Auto properties for ASP.NET AJAX</title>
		<link>http://blog.ashmind.com/2007/10/08/metaprogramming-in-javascript-auto-properties-for-aspnet-ajax/</link>
		<comments>http://blog.ashmind.com/2007/10/08/metaprogramming-in-javascript-auto-properties-for-aspnet-ajax/#comments</comments>
		<pubDate>Mon, 08 Oct 2007 19:20:05 +0000</pubDate>
		<dc:creator>Andrey Shchekin</dc:creator>
				<category><![CDATA[ASP.NET AJAX]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Metaprogramming]]></category>
		<category><![CDATA[Solutions]]></category>

		<guid isPermaLink="false">http://blog.ashmind.com/index.php/2007/10/08/metaprogramming-in-javascript-auto-properties-for-aspnet-ajax/</guid>
		<description><![CDATA[.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; } [...]]]></description>
			<content:encoded><![CDATA[<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>Sometimes, large company is no better than several independent companies.<br /> I always get this thought when looking at ASP.NET AJAX property accessors.</p>
<p>For people not familiar with the matter:<br /> Microsoft ASP.NET AJAX requires developer to use property accessors to encapsulate javascript fields.<br /> This would be a great idea, if only Microsoft IE supported javascript <a href="http://ejohn.org/blog/javascript-getters-and-setters/">getters and setters</a>.<br /> Mozilla supports them, and Opera will in 9.50, but IE does not (they are not standard).<br /> Also, IE does not have any hacky way to achieve the same effect (except in VBScript, which seems to be limited).</p>
<p>So in ASP.NET AJAX each property requires two functions named get<kbd>_propertyName</kbd> and set<kbd>_propertyName</kbd>. </p>
<p>Fortunately, javascript is very powerful in class member manipulation.<br /> So I do not have to write things like this:</p>
<pre class="csharpcode">MyControl.prototype = {
    get_text : <span class="kwrd">function</span>() {
        <span class="kwrd">return</span> <span class="kwrd">this</span>._text;
    },

    set_text : <span class="kwrd">function</span>(value) {
        <span class="kwrd">this</span>._text = value;
    }
}</pre>
<p>And I do not have to wait for auto properties as it is the case for C#.</p>
<p>Instead I just made an helper object named Auto and do things this way:</p>
<pre class="csharpcode">
MyControl.prototype = {…}
Auto.properties(MyControl.prototype, [
    <span class="str">'text'</span>,
    <span class="str">'value'</span>,
    …
]);</pre>
<p>Code for this helper can be very simple.<br />
(in actual project I have additional complexity like Auto support for INotifyPropertyChanged).</p>
<pre class="csharpcode">
<span class="kwrd">var</span> Auto = {
    property : <span class="kwrd">function</span>(prototype, name) {
        <span class="kwrd">var</span> getter = <span class="kwrd">function</span>() { <span class="kwrd">return</span> <span class="kwrd">this</span>[<span class="str">'_'</span> + name]; };
        prototype[<span class="str">'get_'</span> + name] = prototype[<span class="str">'get_'</span> + name] || getter;

        <span class="kwrd">var</span> setter = <span class="kwrd">function</span>(value) { <span class="kwrd">this</span>[<span class="str">'_'</span> + name] = value; };
        prototype[<span class="str">'set_'</span> + name] = prototype[<span class="str">'set_'</span> + name] || setter;
    },

    properties : <span class="kwrd">function</span>(prototype, names) {
        names.forEach(<span class="kwrd">function</span>(name) {
            Auto.property(prototype, name);
        });
    }
}</pre>
<p>This also requires forEach method on Array, but that one is pretty obvious.</p>
<p>I like to show this code when I hear about Javascript being assembly language and whatever-to-javascript compilation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ashmind.com/2007/10/08/metaprogramming-in-javascript-auto-properties-for-aspnet-ajax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

