<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: A sneak peak at ASP.NET AJAX 4.0&#8242;s client-side templating</title>
	<atom:link href="http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/feed/" rel="self" type="application/rss+xml" />
	<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/</link>
	<description>ASP.NET and AJAX code, ideas, and examples.</description>
	<lastBuildDate>Thu, 02 Feb 2012 19:50:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-39383</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Sat, 17 Jul 2010 17:51:08 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-39383</guid>
		<description>Yes, it has definitely been hard to keep up with.  In terms of best practices, I think the recommendation from Microsoft is not to use this stuff at all unless you&#039;ve already built something on the beta.  They&#039;re putting all their energy into jQuery-centric versions of similar functionality, going forward.

You&#039;re correct to question using the CDN on an intranet.  I wouldn&#039;t use it internally either.

What you can do is save the CDN&#039;s files locally and host them on your intranet server.  To use the DataView, I believe just these scripts are needed:

http://ajax.microsoft.com/ajax/act/40412/start.js
http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxCore.js
http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxComponentModel.js
http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxSerialization.js
http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxTemplates.js

Save those all in the same directory, and then reference that local copy of start.js in your page. Sys.require() will load your local copies instead of the ones on the CDN then. Insert a .debug before the .js to retrieve the uncompressed version of any file (e.g. http://ajax.microsoft.com/ajax/act/40412/start.debug.js).

For expanded functionality, like auto-fetching data from web services, the DataContext, oData, etc, get these as well:

http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxNetwork.js
http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxWebServices.js
http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxDataContext.js
http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxOpenData.js</description>
		<content:encoded><![CDATA[<p>Yes, it has definitely been hard to keep up with.  In terms of best practices, I think the recommendation from Microsoft is not to use this stuff at all unless you&#8217;ve already built something on the beta.  They&#8217;re putting all their energy into jQuery-centric versions of similar functionality, going forward.</p>
<p>You&#8217;re correct to question using the CDN on an intranet.  I wouldn&#8217;t use it internally either.</p>
<p>What you can do is save the CDN&#8217;s files locally and host them on your intranet server.  To use the DataView, I believe just these scripts are needed:</p>
<p><a href="http://ajax.microsoft.com/ajax/act/40412/start.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/start.js</a><br />
<a href="http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxCore.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxCore.js</a><br />
<a href="http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxComponentModel.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxComponentModel.js</a><br />
<a href="http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxSerialization.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxSerialization.js</a><br />
<a href="http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxTemplates.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxTemplates.js</a></p>
<p>Save those all in the same directory, and then reference that local copy of start.js in your page. Sys.require() will load your local copies instead of the ones on the CDN then. Insert a .debug before the .js to retrieve the uncompressed version of any file (e.g. <a href="http://ajax.microsoft.com/ajax/act/40412/start.debug.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/start.debug.js</a>).</p>
<p>For expanded functionality, like auto-fetching data from web services, the DataContext, oData, etc, get these as well:</p>
<p><a href="http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxNetwork.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxNetwork.js</a><br />
<a href="http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxWebServices.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxWebServices.js</a><br />
<a href="http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxDataContext.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxDataContext.js</a><br />
<a href="http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxOpenData.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/MicrosoftAjaxOpenData.js</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin Webb</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-39374</link>
		<dc:creator>Robin Webb</dc:creator>
		<pubDate>Sat, 17 Jul 2010 07:33:37 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-39374</guid>
		<description>Thanks again Dave...once again your words are more than worth their weight in gold. In a couple of brief sentences you have both answered by original question and sucessfully pointed me in the correct direction for templating.

In retrospect, I should have personally questioned earlier the difficulty in finding the MicrosoftAjaxTemplates.js library.

Is it just me or is the AJAX client library stuff hard to keep a handle on from a version and best practice in usage perspective? Is there actually a &quot;final&quot; released version of this?

This may be going off topic slightly, but:

I appreciate that things are &quot;simplified&quot; by using the &lt;a href=&quot;http://www.asp.net/ajaxlibrary/CDN.ashx&quot; rel=&quot;nofollow&quot;&gt;CDN&lt;/a&gt; but I&#039;m not clear on best practice within an intranet environment (we have a number of web apps deployed within our organisation). Surely it is quicker to get the scripts from an internal web server rather than to go out to the internet to CDN?

Best wishes.

Robin</description>
		<content:encoded><![CDATA[<p>Thanks again Dave&#8230;once again your words are more than worth their weight in gold. In a couple of brief sentences you have both answered by original question and sucessfully pointed me in the correct direction for templating.</p>
<p>In retrospect, I should have personally questioned earlier the difficulty in finding the MicrosoftAjaxTemplates.js library.</p>
<p>Is it just me or is the AJAX client library stuff hard to keep a handle on from a version and best practice in usage perspective? Is there actually a &#8220;final&#8221; released version of this?</p>
<p>This may be going off topic slightly, but:</p>
<p>I appreciate that things are &#8220;simplified&#8221; by using the <a href="http://www.asp.net/ajaxlibrary/CDN.ashx" rel="nofollow">CDN</a> but I&#8217;m not clear on best practice within an intranet environment (we have a number of web apps deployed within our organisation). Surely it is quicker to get the scripts from an internal web server rather than to go out to the internet to CDN?</p>
<p>Best wishes.</p>
<p>Robin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-39370</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Sat, 17 Jul 2010 03:20:15 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-39370</guid>
		<description>Officially, this DataView stuff was deprecated before it was even released.  However, as you found, there&#039;s a &quot;release&quot; version of it that was bundled with the ACT.  You can get access to that version easier on the CDN (this is the script loader, but the rest of the files are there too): http://ajax.microsoft.com/ajax/act/40412/start.js

However, watch out because this version of MicrosoftTemplates.js doesn&#039;t add dataView to sys.create. So, typical code that worked with the September beta won&#039;t work now without a little modification.

You can either use $create:

&lt;pre lang=&quot;javascript&quot;&gt;&lt;script src=&quot;http://ajax.microsoft.com/ajax/act/40412/start.debug.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  Sys.require([Sys.components.dataView, Sys.components.openDataContext], function () {
    var ds = Sys.create.openDataContext({ serviceUri: &quot;WcfDataService1.svc&quot; });

    $create(Sys.UI.DataView, {
          dataProvider: ds,
          fetchOperation: &quot;Routes&quot;,
          fetchParameters: { $expand: &#039;Airport,Airport1&#039; },
          autoFetch: true
        },
        null,
        null,
        document.getElementById(&#039;airportsView&#039;)
     );
  });
&lt;/script&gt;&lt;/pre&gt;

Or, use the nice jQuery plugin syntax they added at the last minute:

&lt;pre lang=&quot;javascript&quot;&gt;&lt;script src=&quot;http://ajax.microsoft.com/ajax/act/40412/start.debug.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  Sys.require([Sys.scripts.jQuery, Sys.components.dataView, Sys.components.openDataContext], function () {
    var ds = Sys.create.openDataContext({ serviceUri: &quot;WcfDataService1.svc&quot; });

    $(&#039;#airportsView&#039;).dataView({
      dataProvider: ds,
      fetchOperation: &quot;Routes&quot;,
      fetchParameters: { $expand: &#039;Airport,Airport1&#039; },
      autoFetch: true
    });
  });
&lt;/script&gt;&lt;/pre&gt;

Ultimately though, I wouldn&#039;t suggest writing new code against the DataView.  &lt;a href=&quot;http://encosia.com/2010/05/03/a-few-thoughts-on-jquery-templating-with-jquery-tmpl/&quot; rel=&quot;nofollow&quot;&gt;Everyone&#039;s efforts are going into jQuery.tmpl now&lt;/a&gt;, and it will be the preferred method going forward.</description>
		<content:encoded><![CDATA[<p>Officially, this DataView stuff was deprecated before it was even released.  However, as you found, there&#8217;s a &#8220;release&#8221; version of it that was bundled with the ACT.  You can get access to that version easier on the CDN (this is the script loader, but the rest of the files are there too): <a href="http://ajax.microsoft.com/ajax/act/40412/start.js" rel="nofollow">http://ajax.microsoft.com/ajax/act/40412/start.js</a></p>
<p>However, watch out because this version of MicrosoftTemplates.js doesn&#8217;t add dataView to sys.create. So, typical code that worked with the September beta won&#8217;t work now without a little modification.</p>
<p>You can either use $create:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;script src=&quot;http://ajax.microsoft.com/ajax/act/40412/start.debug.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
  Sys.<span style="color: #660066;">require</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>Sys.<span style="color: #660066;">components</span>.<span style="color: #660066;">dataView</span><span style="color: #339933;">,</span> Sys.<span style="color: #660066;">components</span>.<span style="color: #660066;">openDataContext</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> ds <span style="color: #339933;">=</span> Sys.<span style="color: #660066;">create</span>.<span style="color: #660066;">openDataContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> serviceUri<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;WcfDataService1.svc&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    $create<span style="color: #009900;">&#40;</span>Sys.<span style="color: #660066;">UI</span>.<span style="color: #660066;">DataView</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
          dataProvider<span style="color: #339933;">:</span> ds<span style="color: #339933;">,</span>
          fetchOperation<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Routes&quot;</span><span style="color: #339933;">,</span>
          fetchParameters<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> $expand<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Airport,Airport1'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
          autoFetch<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span>
        <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span>
        document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'airportsView'</span><span style="color: #009900;">&#41;</span>
     <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Or, use the nice jQuery plugin syntax they added at the last minute:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;script src=&quot;http://ajax.microsoft.com/ajax/act/40412/start.debug.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
  Sys.<span style="color: #660066;">require</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>Sys.<span style="color: #660066;">scripts</span>.<span style="color: #660066;">jQuery</span><span style="color: #339933;">,</span> Sys.<span style="color: #660066;">components</span>.<span style="color: #660066;">dataView</span><span style="color: #339933;">,</span> Sys.<span style="color: #660066;">components</span>.<span style="color: #660066;">openDataContext</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> ds <span style="color: #339933;">=</span> Sys.<span style="color: #660066;">create</span>.<span style="color: #660066;">openDataContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> serviceUri<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;WcfDataService1.svc&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#airportsView'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">dataView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      dataProvider<span style="color: #339933;">:</span> ds<span style="color: #339933;">,</span>
      fetchOperation<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Routes&quot;</span><span style="color: #339933;">,</span>
      fetchParameters<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> $expand<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Airport,Airport1'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      autoFetch<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Ultimately though, I wouldn&#8217;t suggest writing new code against the DataView.  <a href="http://encosia.com/2010/05/03/a-few-thoughts-on-jquery-templating-with-jquery-tmpl/" rel="nofollow">Everyone&#8217;s efforts are going into jQuery.tmpl now</a>, and it will be the preferred method going forward.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin Webb</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-39368</link>
		<dc:creator>Robin Webb</dc:creator>
		<pubDate>Fri, 16 Jul 2010 18:47:06 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-39368</guid>
		<description>Just wondered if you had an updated version that worked with the release version of Visual Studio 2010? 

Finally managed to track down the MicrosoftAjaxTemplates.js being as an embedded resource in 4.1.40412.0 version of AjaxControlToolkit.dll.

Although this is not referenced from the ToolScriptManager necessitating an extract of the js file using Reflector.

Is it really this hard?</description>
		<content:encoded><![CDATA[<p>Just wondered if you had an updated version that worked with the release version of Visual Studio 2010? </p>
<p>Finally managed to track down the MicrosoftAjaxTemplates.js being as an embedded resource in 4.1.40412.0 version of AjaxControlToolkit.dll.</p>
<p>Although this is not referenced from the ToolScriptManager necessitating an extract of the js file using Reflector.</p>
<p>Is it really this hard?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Top 10 Upcoming Microsoft Releases That Developers Should be Excited About &#124; Garrett&#39;s Tech Musings</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-36786</link>
		<dc:creator>Top 10 Upcoming Microsoft Releases That Developers Should be Excited About &#124; Garrett&#39;s Tech Musings</dc:creator>
		<pubDate>Sat, 17 Oct 2009 14:19:26 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-36786</guid>
		<description>[...] which provides an easier and simpler method of displaying dynamic data.  Take a look at this overview to get an idea of how this all works and how this brings pure AJAX and JSON data interaction into [...]</description>
		<content:encoded><![CDATA[<p>[...] which provides an easier and simpler method of displaying dynamic data.  Take a look at this overview to get an idea of how this all works and how this brings pure AJAX and JSON data interaction into [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ward</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-36003</link>
		<dc:creator>Dave Ward</dc:creator>
		<pubDate>Wed, 29 Jul 2009 17:25:11 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-36003</guid>
		<description>You can use:

&lt;pre lang=&quot;javascript&quot;&gt;code:after=&quot;$element.innerHTML = YourHTMLField;&quot;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>You can use:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">code<span style="color: #339933;">:</span>after<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;$element.innerHTML = YourHTMLField;&quot;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Henk</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-35940</link>
		<dc:creator>Henk</dc:creator>
		<pubDate>Thu, 23 Jul 2009 22:42:41 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-35940</guid>
		<description>All works fine, but what if I have some HTML markup in JSON data, such as B, I, U, etc tags? As I can see all markup is escaped :(
Does anyone has a solution? May be i&#039;m doing something wrong?</description>
		<content:encoded><![CDATA[<p>All works fine, but what if I have some HTML markup in JSON data, such as B, I, U, etc tags? As I can see all markup is escaped :(<br />
Does anyone has a solution? May be i&#8217;m doing something wrong?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Evans</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-34162</link>
		<dc:creator>Steve Evans</dc:creator>
		<pubDate>Fri, 20 Feb 2009 12:25:43 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-34162</guid>
		<description>Dave, thanks for the update regarding this. 

I think that while the example you provided doesn&#039;t quite fit what I want to do, in that I have table headings that I also don&#039;t want to be visible unless some results are returned, it certainly is useful to know about using the itemPlaceHolder property of the DataView.

I guess what I&#039;ll need to do is to make the whole table not visble prior to binding and then once the DataBinding has occurred look to see if data was retrieved and then just make the table vsisible or not.

Thanks again.</description>
		<content:encoded><![CDATA[<p>Dave, thanks for the update regarding this. </p>
<p>I think that while the example you provided doesn&#8217;t quite fit what I want to do, in that I have table headings that I also don&#8217;t want to be visible unless some results are returned, it certainly is useful to know about using the itemPlaceHolder property of the DataView.</p>
<p>I guess what I&#8217;ll need to do is to make the whole table not visble prior to binding and then once the DataBinding has occurred look to see if data was retrieved and then just make the table vsisible or not.</p>
<p>Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Reed</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-34143</link>
		<dc:creator>Dave Reed</dc:creator>
		<pubDate>Thu, 19 Feb 2009 00:30:21 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-34143</guid>
		<description>Steve -- in the earlier bits, if you set the item template of a DataView, it was ok if it was contained within the DataView, because we implied that the item placeholder is where the template is. For various reasons, we changed that in the next preview release. Now, if you set itemTemplate, the template can&#039;t be a child of the DataView. So, actually you get one little feature out of that, in that the stuff initially inside the table of the DataView is what shows up prior to any data being loaded (you may even have a cell or something that says &#039;now loading...&#039;).

So you will need to build a table that contains a placeholder describing where the template instances should go, and seperately define a template table. Something like this:

&lt;pre lang=&quot;html&quot;&gt;&lt;table id=&quot;results&quot;&gt;
  &lt;tbody&gt;
     &lt;tr id=&quot;ph&quot;&gt;
        &lt;td&gt;Now Loading...&lt;/td&gt;
     &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;


&lt;table style=&quot;display:hidden&quot;&gt;
  &lt;tbody id=&quot;searchResultItems&quot; class=&quot;sys-template&quot;&gt;
      &lt;tr&gt;&lt;td&gt;...&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/pre&gt;

Then do what you are doing except also set dataView.set_itemPlaceholder to the ph element. When the DataView renders, the placeholder element (the TR containing the TD &quot;now loading&quot;) is completely removed, and the instances of the template are inserted into the tbody at the point where it was. So that also means, by the way, you can define header/footer rows, like so:

&lt;pre lang=&quot;html&quot;&gt;&lt;table id=&quot;results&quot;&gt;
  &lt;tbody&gt;
     &lt;tr&gt;&lt;td&gt;header&lt;/td&gt;&lt;/tr&gt;
     &lt;tr id=&quot;ph&quot;&gt;
        &lt;td&gt;Now Loading...&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;&lt;td&gt;footer&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/pre&gt;

Hope that helps.</description>
		<content:encoded><![CDATA[<p>Steve &#8212; in the earlier bits, if you set the item template of a DataView, it was ok if it was contained within the DataView, because we implied that the item placeholder is where the template is. For various reasons, we changed that in the next preview release. Now, if you set itemTemplate, the template can&#8217;t be a child of the DataView. So, actually you get one little feature out of that, in that the stuff initially inside the table of the DataView is what shows up prior to any data being loaded (you may even have a cell or something that says &#8216;now loading&#8230;&#8217;).</p>
<p>So you will need to build a table that contains a placeholder describing where the template instances should go, and seperately define a template table. Something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;table</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;results&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tbody&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ph&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></span>Now Loading...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tbody&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table&gt;</span></span>
&nbsp;
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;table</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;display:hidden&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tbody</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;searchResultItems&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sys-template&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;">&lt;tr&gt;&lt;td&gt;</span>...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #66cc66;">/</span>td&gt;&lt;<span style="color: #66cc66;">/</span>tr&gt;</span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tbody&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table&gt;</span></span></pre></div></div>

<p>Then do what you are doing except also set dataView.set_itemPlaceholder to the ph element. When the DataView renders, the placeholder element (the TR containing the TD &#8220;now loading&#8221;) is completely removed, and the instances of the template are inserted into the tbody at the point where it was. So that also means, by the way, you can define header/footer rows, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;table</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;results&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tbody&gt;</span></span>
     <span style="color: #009900;">&lt;tr&gt;&lt;td&gt;</span>header<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #66cc66;">/</span>td&gt;&lt;<span style="color: #66cc66;">/</span>tr&gt;</span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ph&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></span>Now Loading...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span>
     <span style="color: #009900;">&lt;tr&gt;&lt;td&gt;</span>footer<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #66cc66;">/</span>td&gt;&lt;<span style="color: #66cc66;">/</span>tr&gt;</span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tbody&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table&gt;</span></span></pre></div></div>

<p>Hope that helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Evans</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-34121</link>
		<dc:creator>Steve Evans</dc:creator>
		<pubDate>Tue, 17 Feb 2009 09:30:52 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-34121</guid>
		<description>I&#039;m not sure if anyone is still monitoring this thread or not but just in case.

I am having trouble binding a DataView where the template is inside a table. What I want to be able to do is have the template for the DataView be a tbody that will repeat for the number of search results returned by the DataSource assigned to my DataView. I therefore don’t want any of the table visible should zero results be returned.

In Dave&#039;s comment he mentions that I should attach the DataView to the table but point the template at the tbody.
I have tried a number of different things here but may just be doing something obviously wrong. 

What I have so far is:
searchResultsListView = $create(Sys.UI.DataView, { dataSource: searchResultsDataSource }, { itemCreated: onSearchResultItemCreated }, {}, $get(&#039;results&#039;));
searchResultsListView.set_itemTemplate(&#039;searchResultItems&#039;);

Where &#039;results&#039; is the whole table and is &#039;searchResultItems&#039; what should be the repeating tbody.

The error that I get is being thrown from Sys$UI$DataView$_getTemplate() where it does this:

if ((e !== template) &amp;&amp; this._elementContains(e, template, true)) {
throw Error.invalidOperation(Sys.TemplateRes.misplacedTemplate);
}

And the error is: &#039;DataView item template must not be a child element of the DataView.&#039; 

The template is searchResultsItem and e (element) is the results (the table that will contain the repeated items).</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure if anyone is still monitoring this thread or not but just in case.</p>
<p>I am having trouble binding a DataView where the template is inside a table. What I want to be able to do is have the template for the DataView be a tbody that will repeat for the number of search results returned by the DataSource assigned to my DataView. I therefore don’t want any of the table visible should zero results be returned.</p>
<p>In Dave&#8217;s comment he mentions that I should attach the DataView to the table but point the template at the tbody.<br />
I have tried a number of different things here but may just be doing something obviously wrong. </p>
<p>What I have so far is:<br />
searchResultsListView = $create(Sys.UI.DataView, { dataSource: searchResultsDataSource }, { itemCreated: onSearchResultItemCreated }, {}, $get(&#8216;results&#8217;));<br />
searchResultsListView.set_itemTemplate(&#8216;searchResultItems&#8217;);</p>
<p>Where &#8216;results&#8217; is the whole table and is &#8216;searchResultItems&#8217; what should be the repeating tbody.</p>
<p>The error that I get is being thrown from Sys$UI$DataView$_getTemplate() where it does this:</p>
<p>if ((e !== template) &amp;&amp; this._elementContains(e, template, true)) {<br />
throw Error.invalidOperation(Sys.TemplateRes.misplacedTemplate);<br />
}</p>
<p>And the error is: &#8216;DataView item template must not be a child element of the DataView.&#8217; </p>
<p>The template is searchResultsItem and e (element) is the results (the table that will contain the repeated items).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fonny Lasmana</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-33980</link>
		<dc:creator>Fonny Lasmana</dc:creator>
		<pubDate>Thu, 29 Jan 2009 14:45:23 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-33980</guid>
		<description>Can you help me translate this to VB? I used codechanger.com but it fails to convert properly. 

[WebMethod]
public static IEnumerable GetFeedburnerItems()
{
  XDocument feedXML = 
    XDocument.Load(&quot;http://feeds.encosia.com/Encosia&quot;);
 
  var feeds = 
    from feed in feedXML.Descendants(&quot;item&quot;)
    select new
    {
      Date = DateTime.Parse(feed.Element(&quot;pubDate&quot;).Value)
                     .ToShortDateString(),
      Title = feed.Element(&quot;title&quot;).Value,
      Link = feed.Element(&quot;link&quot;).Value,
      Description = feed.Element(&quot;description&quot;).Value
    };
 
  return feeds;
}

PS: I got error message when VB web service returns IENumerable datatype: Can&#039;t serialize IENumerable.</description>
		<content:encoded><![CDATA[<p>Can you help me translate this to VB? I used codechanger.com but it fails to convert properly. </p>
<p>[WebMethod]<br />
public static IEnumerable GetFeedburnerItems()<br />
{<br />
  XDocument feedXML =<br />
    XDocument.Load(&#8220;http://feeds.encosia.com/Encosia&#8221;);</p>
<p>  var feeds =<br />
    from feed in feedXML.Descendants(&#8220;item&#8221;)<br />
    select new<br />
    {<br />
      Date = DateTime.Parse(feed.Element(&#8220;pubDate&#8221;).Value)<br />
                     .ToShortDateString(),<br />
      Title = feed.Element(&#8220;title&#8221;).Value,<br />
      Link = feed.Element(&#8220;link&#8221;).Value,<br />
      Description = feed.Element(&#8220;description&#8221;).Value<br />
    };</p>
<p>  return feeds;<br />
}</p>
<p>PS: I got error message when VB web service returns IENumerable datatype: Can&#8217;t serialize IENumerable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rem</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-33103</link>
		<dc:creator>Rem</dc:creator>
		<pubDate>Tue, 04 Nov 2008 14:16:51 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-33103</guid>
		<description>Nice blog...</description>
		<content:encoded><![CDATA[<p>Nice blog&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raghu Rajbhandari</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-32659</link>
		<dc:creator>Raghu Rajbhandari</dc:creator>
		<pubDate>Tue, 21 Oct 2008 12:26:58 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-32659</guid>
		<description>It didn&#039;t work in IE on my end.</description>
		<content:encoded><![CDATA[<p>It didn&#8217;t work in IE on my end.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raghu Rajbhandari</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-32654</link>
		<dc:creator>Raghu Rajbhandari</dc:creator>
		<pubDate>Tue, 21 Oct 2008 11:17:01 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-32654</guid>
		<description>The sample didn&#039;t work on my end.</description>
		<content:encoded><![CDATA[<p>The sample didn&#8217;t work on my end.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thanigainathan.S</title>
		<link>http://encosia.com/sneak-peak-aspnet-ajax-4-client-side-templating/#comment-32635</link>
		<dc:creator>Thanigainathan.S</dc:creator>
		<pubDate>Mon, 20 Oct 2008 19:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://encosia.com/?p=86#comment-32635</guid>
		<description>Hi,

This is a nice article.Helped very much with ajax preview 2 experimenting.

Thanks,
Thani</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>This is a nice article.Helped very much with ajax preview 2 experimenting.</p>
<p>Thanks,<br />
Thani</p>
]]></content:encoded>
	</item>
</channel>
</rss>

