<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Alex Tsung's Weblog</title>
	<atom:link href="http://atsung.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://atsung.wordpress.com</link>
	<description>ASP.NET related</description>
	<lastBuildDate>Thu, 04 Jun 2009 07:09:30 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/d03430f7c9167f70228686d34687eb35?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Alex Tsung's Weblog</title>
		<link>http://atsung.wordpress.com</link>
	</image>
			<item>
		<title>Wishlist for Velocity (CPT4?)</title>
		<link>http://atsung.wordpress.com/2009/06/04/wishlist-for-velocity-cpt4/</link>
		<comments>http://atsung.wordpress.com/2009/06/04/wishlist-for-velocity-cpt4/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 07:08:55 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Distribued Cache]]></category>
		<category><![CDATA[Velocity]]></category>
		<category><![CDATA[Distributed Cache]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=156</guid>
		<description><![CDATA[I went to Rob&#8217;s presentation on Velocity tonight, it&#8217;s a great presentation and a lot of information shared with audience.
I prepare a wishlist for Velocity (CPT4 or next beta release) and hope the Velocity team can take my wishlist into consideration.

A new method: bool DataCache.ContainsRegion(string region).

This method checks if the region exists in the named [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=156&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I went to <a href="http://weblogs.asp.net/rchartier/" target="_blank">Rob</a>&#8217;s <a href="http://tinyurl.com/RobVelocity" target="_blank">presentation on Velocity</a> tonight, it&#8217;s a great presentation and a lot of information shared with audience.</p>
<p>I prepare a wishlist for Velocity (CPT4 or next beta release) and hope the Velocity team can take my wishlist into consideration.</p>
<ol>
<li>A new method: <span style="color:#ff6600;">bool DataCache.ContainsRegion(string region)</span>.
<ul>
<li>This method checks if the region exists in the named cache or not.</li>
<li>See my <a href="http://atsung.wordpress.com/2009/06/01/velocity-how-do-i-know-if-a-cache-region-is-created/" target="_blank">previous post</a> for details.</li>
</ul>
</li>
<li>Update the method <span style="color:#ff6600;">DataCache.GetObjectsByAnyTag(List&lt;DataCacheTag&gt; tags, string region)</span> so the keys of returned cache items are unique.
<ul>
<li>Make sure the cache key is not contained in the keys, then add the item into the collection.</li>
<li>See my <a href="http://atsung.wordpress.com/2009/06/01/velocity-ctp3-datacache-getobjectsbyanytag-method/" target="_blank">previous post</a> for example.</li>
</ul>
</li>
<li>Make sure the default region name is not arbitratry.
<ul>
<li><span style="color:#ff6600;">DataCache.GetCacheItem</span> Method &#8211; Gets a <span style="color:#ff6600;">DataCacheItem</span> object to retrieve all information associated with your cached object in the cluster.</li>
<li><span style="color:#ff6600;">DataCache.GetCacheItem (String)</span> -&gt; Gets a DataCacheItem object to retrieve all information associated with your cached object in the cluster.</li>
<li><span style="color:#ff6600;">DataCache.GetCacheItem (String, String)</span> -&gt; Gets a DataCacheItem object to retrieve all information associated with your cached object in the cluster. For objects stored in regions.</li>
<li>When using the <span style="color:#ff6600;">DataCache.GetCacheItem (String)</span> method (without region specified), the return object&#8217;s property -<span style="color:#ff6600;">RegionName</span> &#8211; is kind of arbitrary.</li>
</ul>
</li>
<li>A new commad for administrators to create region in PowerShell.
<ul>
<li><span style="color:#ff6600;">New-CacheRegion [-CacheName] &lt;CacheName&gt; [-RegionName] &lt;RegionName&gt;</span></li>
<li>Example 1:
<ul>
<li>New-CacheRegion -CacheName Products -RegionName MyRegion -&gt; this creates a region &#8220;MyRegion&#8221; in the named cache &#8220;Products&#8221;.</li>
</ul>
</li>
<li>Example 2:
<ul>
<li>New-CacheRegion -RegionName MyRegion -&gt; this creates a region &#8220;MyRegion&#8221; in the default cache &#8220;default&#8221;</li>
</ul>
</li>
</ul>
</li>
</ol>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/156/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=156&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2009/06/04/wishlist-for-velocity-cpt4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2008 (SP1) Team System Profiler causes blue screen on Intel Core i7 processor</title>
		<link>http://atsung.wordpress.com/2009/06/02/visual-studio-2008-sp1-team-system-profiler-causes-blue-screen-on-intel-core-i7-processor/</link>
		<comments>http://atsung.wordpress.com/2009/06/02/visual-studio-2008-sp1-team-system-profiler-causes-blue-screen-on-intel-core-i7-processor/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 17:54:26 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[Team System Profiler]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=148</guid>
		<description><![CDATA[Yesterday I used the VS2008 (SP1) Team System Profiler to test the performance of the web application at work, it caused blue screen three times. I didn&#8217;t know what happen but I suspect it&#8217;s a hardware conflict, so I did a search and found the Knowledge Base from Microsoft:
http://code.msdn.microsoft.com/KB958842
Symptoms
You may experience a stop error or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=148&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Yesterday I used the VS2008 (SP1) Team System Profiler to test the performance of the web application at work, it caused blue screen three times. I didn&#8217;t know what happen but I suspect it&#8217;s a hardware conflict, so I did a search and found the Knowledge Base from Microsoft:</p>
<p><a href="http://code.msdn.microsoft.com/KB958842">http://code.msdn.microsoft.com/KB958842</a></p>
<p><span style="color:#ff6600;"><em><span style="text-decoration:underline;"><strong>Symptoms</strong></span><br />
You may experience a stop error or a crash on the operating system when you profile an application by using Microsoft Visual Studio 2008 Service Pack 1 (SP1). The problem occurs when the following conditions are true:<br />
• You use the sampling profiling method.<br />
• The computer is running on the Intel Nehalem processor. </em></span></p>
<p><span style="color:#ff6600;"><em><span style="text-decoration:underline;"><strong>Cause</strong></span><br />
This problem occurs because the sampling profiler uses drivers in operating system. However, the Intel Nehalem processor was created after the 2008 version of the profiler.</em></span></p>
<p><span style="color:#ff6600;"><em><strong>Additional Information about the issue resolved by this Hotfix can be found in its Knowledge Base article at <a href="http://support.microsoft.com/kb/958842">http://support.microsoft.com/kb/958842</a></strong></em></span></p>
<p><span style="color:#ff6600;"><span style="text-decoration:underline;"><em><strong>Additional Hotfixes</strong></em></span><em><br />
Search the list of all other publicly available Visual Studio and .NET Framework Hotfixes at <a href="http://code.msdn.microsoft.com/Project/ProjectDirectory.aspx?TagName=Hotfix&amp;ProjectSearchText=Hotfix">http://code.msdn.microsoft.com/Project/ProjectDirectory.aspx?TagName=Hotfix&amp;ProjectSearchText=Hotfix</a>*</em></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=148&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2009/06/02/visual-studio-2008-sp1-team-system-profiler-causes-blue-screen-on-intel-core-i7-processor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>
	</item>
		<item>
		<title>Velocity (CTP3) &#8211; DataCache.GetObjectsByAnyTag Method</title>
		<link>http://atsung.wordpress.com/2009/06/01/velocity-ctp3-datacache-getobjectsbyanytag-method/</link>
		<comments>http://atsung.wordpress.com/2009/06/01/velocity-ctp3-datacache-getobjectsbyanytag-method/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 01:35:43 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Distribued Cache]]></category>
		<category><![CDATA[Velocity]]></category>
		<category><![CDATA[CTP3]]></category>
		<category><![CDATA[Data Cache]]></category>
		<category><![CDATA[Distributed Cache]]></category>
		<category><![CDATA[GetObjectsByAnyTag]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=126</guid>
		<description><![CDATA[I was writing some code to experiment the Tag search in Velocity CTP3 and I found there is some small bug in one of the get objects by tag methods &#8211; DataCache.GetObjectsByAnyTag.
The definition of the method of DataCache.GetObjectsByAnyTag is:
Gets an enumerable list of all cached objects in the specified region that have any of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=126&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I was writing some code to experiment the Tag search in Velocity CTP3 and I found there is some small bug in one of the get objects by tag methods &#8211; <em>DataCache.GetObjectsByAnyTag</em>.</p>
<p>The definition of the method of <em>DataCache.GetObjectsByAnyTag</em> is:</p>
<p><span style="color:#000000;"><span style="text-decoration:underline;"><span style="color:#ff6600;">Gets an enumerable list of all cached objects in the specified region that have any of the same tags in common.</span></span></span></p>
<p>For example I have 3 cache items:</p>
<p>Item 1: key = &#8220;111&#8243;, content = &#8220;aaa&#8221;, tag = &#8220;a&#8221;</p>
<p>Item 2: key = &#8220;222&#8243;, content = &#8220;bbb&#8221;, tag = &#8220;b&#8221;</p>
<p>Item 3: key = &#8220;333&#8243;, content = &#8220;ccc&#8221;, tag = &#8220;a,b,c&#8221;</p>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">Here are some scenarios:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">(1) If I search with Tag &#8220;a&#8221; via DataCache.GetObjectsByAnyTag(&lt;a&gt;, &#8220;my_region&#8221;), I get:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">Item 1: key = &#8220;111&#8243;, content = &#8220;aaa&#8221;, tag = &#8220;a&#8221;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">Item 3: key = &#8220;333&#8243;, content = &#8220;ccc&#8221;, tag = &#8220;a,b,c&#8221;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">(2) If I search with Tag &#8220;b&#8221; via DataCache.GetObjectsByAnyTag(&lt;b&gt;, &#8220;my_region&#8221;), I get:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">Item 2: key = &#8220;222&#8243;, content = &#8220;bbb&#8221;, tag = &#8220;b&#8221;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">(3) But if I search with Tags &#8220;a,b&#8221; via DataCache.GetObjectsByAnyTag(&lt;a, b&gt;, &#8220;my_region&#8221;), I get:</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">Item 1: key = &#8220;111&#8243;, content = &#8220;aaa&#8221;, tag = &#8220;a&#8221;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">Item 3: key = &#8220;333&#8243;, content = &#8220;ccc&#8221;, tag = &#8220;a,b,c&#8221;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">Item 3: key = &#8220;333&#8243;, content = &#8220;ccc&#8221;, tag = &#8220;a,b,c&#8221;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">Item 2: key = &#8220;222&#8243;, content = &#8220;bbb&#8221;, tag = &#8220;b&#8221;</div>
<p>Here are some scenarios:</p>
<p><strong>(1)</strong> If I search with Tag &#8220;a&#8221; via DataCache.GetObjectsByAnyTag(&lt;a&gt;, &#8220;my_region&#8221;), I get:</p>
<p>Item 1: key = &#8220;111&#8243;, content = &#8220;aaa&#8221;, tag = &#8220;a&#8221;</p>
<p>Item 3: key = &#8220;333&#8243;, content = &#8220;ccc&#8221;, tag = &#8220;a,b,c&#8221;</p>
<p><strong>(2)</strong> If I search with Tag &#8220;b&#8221; via DataCache.GetObjectsByAnyTag(&lt;b&gt;, &#8220;my_region&#8221;), I get:</p>
<p>Item 2: key = &#8220;222&#8243;, content = &#8220;bbb&#8221;, tag = &#8220;b&#8221;</p>
<p>Item 3: key = &#8220;333&#8243;, content = &#8220;ccc&#8221;, tag = &#8220;a,b,c&#8221;</p>
<p><strong>(3)</strong> But if I search with Tags &#8220;a,b&#8221; via DataCache.GetObjectsByAnyTag(&lt;a, b&gt;, &#8220;my_region&#8221;), I get:</p>
<p>Item 1: key = &#8220;111&#8243;, content = &#8220;aaa&#8221;, tag = &#8220;a&#8221;</p>
<p>Item 2: key = &#8220;222&#8243;, content = &#8220;bbb&#8221;, tag = &#8220;b&#8221;</p>
<p>Item 3: key = &#8220;333&#8243;, content = &#8220;ccc&#8221;, tag = &#8220;a,b,c&#8221;</p>
<p>Item 3: key = &#8220;333&#8243;, content = &#8220;ccc&#8221;, tag = &#8220;a,b,c&#8221;</p>
<p>In scenario <strong>(3)</strong>, the item 3 has been added twice because its tags are &#8220;a,b,c&#8221; and I search by &lt;a,b&gt; (Any Tag).</p>
<p>I believe this method - <em>DataCache.GetObjectsByAnyTag - <span style="font-style:normal;"><span style="text-decoration:underline;"><span style="color:#ff6600;"><span style="font-style:normal;"><span style="text-decoration:none;">should check if the cache key is contained in the collection, if not, then add it to the collection</span></span></span></span></span><span style="font-style:normal;"> &#8211; unless the velocity team want the developers do the checking of duplicated key in the caller program.</span></em></p>
<p>I will list my code and some screenshots.</p>
<p><em><span style="font-style:normal;">The first file is CacheWorker.cs:</span></em></p>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;"><span style="color:blue;">using</span> System;</p>
<p style="margin:0;"><span style="color:blue;">using</span> Microsoft.Data.Caching;</p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">namespace</span> VelocityTest</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">CacheWorker</span></p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">const</span> <span style="color:blue;">string</span> DEFAULT_CACHE_REGION = <span style="color:#a31515;">&#8220;Default_Cache_Region&#8221;</span>;</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:blue;">object</span> _synclock = <span style="color:blue;">new</span> <span style="color:blue;">object</span>();</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">CacheWorker</span> _cacheWorker = <span style="color:blue;">null</span>;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">DataCacheFactory</span> _cacheFactory = <span style="color:blue;">null</span>;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">DataCache</span> _defaultCache = <span style="color:blue;">null</span>;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">DataCache</span> _eventCache = <span style="color:blue;">null</span>;</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> CacheWorker()</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">CacheWorker</span> Instance</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">get</span></p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">lock</span> (_synclock)</p>
<p style="padding-left:120px;margin:0;">{</p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">try</span></p>
<p style="padding-left:150px;margin:0;">{</p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">if</span> (_cacheWorker == <span style="color:blue;">null</span>)</p>
<p style="padding-left:180px;margin:0;">{</p>
<p style="padding-left:210px;margin:0;">_cacheWorker = <span style="color:blue;">new</span> <span style="color:#2b91af;">CacheWorker</span>();</p>
<p style="padding-left:210px;margin:0;">
<p style="padding-left:210px;margin:0;"><span style="color:green;">// we use configuration file</span></p>
<p style="padding-left:210px;margin:0;">_cacheFactory = <span style="color:blue;">new</span> <span style="color:#2b91af;">DataCacheFactory</span>();</p>
<p style="padding-left:210px;margin:0;">
<p style="padding-left:210px;margin:0;"><span style="color:green;">// default cache</span></p>
<p style="padding-left:210px;margin:0;">_defaultCache = _cacheFactory.GetDefaultCache();</p>
<p style="padding-left:210px;margin:0;">
<p style="padding-left:210px;margin:0;">_defaultCache.RemoveRegion(DEFAULT_CACHE_REGION);</p>
<p style="padding-left:210px;margin:0;">_defaultCache.CreateRegion(DEFAULT_CACHE_REGION, <span style="color:blue;">true</span>);</p>
<p style="padding-left:210px;margin:0;">
<p style="padding-left:210px;margin:0;"><span style="color:green;">// names cache</span></p>
<p style="padding-left:210px;margin:0;">_eventCache = _cacheFactory.GetCache(<span style="color:#a31515;">&#8220;Event2&#8243;</span>);</p>
<p style="padding-left:180px;margin:0;">}</p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">return</span> _cacheWorker;</p>
<p style="padding-left:150px;margin:0;">}</p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">catch</span> (<span style="color:#2b91af;">DataCacheException</span> ex)</p>
<p style="padding-left:150px;margin:0;">{</p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">return</span> <span style="color:blue;">null</span>;</p>
<p style="padding-left:150px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:#2b91af;">DataCacheFactory</span> CacheFactory</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">get</span> { <span style="color:blue;">return</span> _cacheFactory; }</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:#2b91af;">DataCache</span> DefaultCache</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">get</span> { <span style="color:blue;">return</span> _defaultCache; }</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:#2b91af;">DataCache</span> EventCache</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">get</span> { <span style="color:blue;">return</span> _eventCache; }</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:#2b91af;">DataCacheItemVersion</span> AddCache(<span style="color:blue;">string</span> key, <span style="color:blue;">object</span> value, <span style="color:#2b91af;">TimeSpan</span>? timeout)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:#2b91af;">DataCacheItemVersion</span> version = <span style="color:blue;">null</span>;</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">if</span> (timeout.HasValue)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;">version = _defaultCache.Put(key, value, timeout.Value);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">else</span></p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;">version = _defaultCache.Put(key, value);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">return</span> version;</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="margin:0;">}</p>
</div>
<p>The second file is Default3.aspx page:</p>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;"><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">@</span> <span style="color:#a31515;">Page</span> <span style="color:red;">Language</span><span style="color:blue;">=&#8221;C#&#8221;</span> <span style="color:red;">AutoEventWireup</span><span style="color:blue;">=&#8221;true&#8221;</span> <span style="color:red;">CodeBehind</span><span style="color:blue;">=&#8221;Default3.aspx.cs&#8221;</span> <span style="color:red;">Inherits</span><span style="color:blue;">=&#8221;VelocityTest.Default3&#8243;</span> <span style="background:#ffee62;">%&gt;</span></p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">&lt;!</span><span style="color:#a31515;">DOCTYPE</span> <span style="color:red;">html</span> <span style="color:red;">PUBLIC</span> <span style="color:blue;">&#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;</span> <span style="color:blue;">&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</span></p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">html</span> <span style="color:red;">xmlns</span><span style="color:blue;">=&#8221;http://www.w3.org/1999/xhtml&#8221;</span> <span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">head</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span>Velocity &#8211; Tag Example<span style="color:blue;">&lt;/</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">head</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">form</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;form1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">p</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">h3</span><span style="color:blue;">&gt;</span>Velocity &#8211; Tag Example<span style="color:blue;">&lt;/</span><span style="color:#a31515;">h3</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">table</span> <span style="color:red;">border</span><span style="color:blue;">=&#8221;0&#8243;</span> <span style="color:red;">cellpadding</span><span style="color:blue;">=&#8221;2&#8243;&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:#a31515;">b</span><span style="color:blue;">&gt;</span>Cache Key<span style="color:blue;">&lt;/</span><span style="color:#a31515;">b</span><span style="color:blue;">&gt;&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TextBox</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;txtCacheKey&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">RequiredFieldValidator</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;vadCacheKey&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">ControlToValidate</span><span style="color:blue;">=&#8221;txtCacheKey&#8221;</span> <span style="color:red;">ErrorMessage</span><span style="color:blue;">=&#8221;* required&#8221;</span> <span style="color:red;">Display</span><span style="color:blue;">=&#8221;Dynamic&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:#a31515;">b</span><span style="color:blue;">&gt;</span>Cache Content<span style="color:blue;">&lt;/</span><span style="color:#a31515;">b</span><span style="color:blue;">&gt;&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TextBox</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;txtCacheContent&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">RequiredFieldValidator</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;vadCacheContent&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">ControlToValidate</span><span style="color:blue;">=&#8221;txtCacheContent&#8221;</span> <span style="color:red;">ErrorMessage</span><span style="color:blue;">=&#8221;* required&#8221;</span> <span style="color:red;">Display</span><span style="color:blue;">=&#8221;Dynamic&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:#a31515;">b</span><span style="color:blue;">&gt;</span>Cache Tags<span style="color:blue;">&lt;/</span><span style="color:#a31515;">b</span><span style="color:blue;">&gt;&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TextBox</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;txtCacheTag&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:blue;">/&gt;</span>(Tags are seperated by comma)<span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span><span style="color:red;">&amp;nbsp;</span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;btnCancel&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;Cancel&#8221;</span> <span style="color:red;">CausesValidation</span><span style="color:blue;">=&#8221;false&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;btnSave&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;Save&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">table</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">p</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">hr</span> <span style="color:blue;">/&gt;</span></p>
<p style="margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">p</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">table</span> <span style="color:red;">border</span><span style="color:blue;">=&#8221;0&#8243;</span> <span style="color:red;">cellpadding</span><span style="color:blue;">=&#8221;2&#8243;&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:#a31515;">b</span><span style="color:blue;">&gt;</span>Search Method:<span style="color:blue;">&lt;/</span><span style="color:#a31515;">b</span><span style="color:blue;">&gt;&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">RadioButtonList</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;radSearchMethodList&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">RepeatDirection</span><span style="color:blue;">=&#8221;Horizontal&#8221;&gt;</span></p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">ListItem</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;No Tag&#8221;</span> <span style="color:red;">Value</span><span style="color:blue;">=&#8221;NoTag&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">ListItem</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;All Tags&#8221;</span> <span style="color:red;">Value</span><span style="color:blue;">=&#8221;AllTags&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">ListItem</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;Any Tag&#8221;</span> <span style="color:red;">Value</span><span style="color:blue;">=&#8221;AnyTag&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">ListItem</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;One Tag&#8221;</span> <span style="color:red;">Value</span><span style="color:blue;">=&#8221;OneTag&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">RadioButtonList</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:#a31515;">b</span><span style="color:blue;">&gt;</span>Search Tags:<span style="color:blue;">&lt;/</span><span style="color:#a31515;">b</span><span style="color:blue;">&gt;&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TextBox</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;txtSearchTag&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:blue;">/&gt;</span>(Tags are seperated by comma)<span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span><span style="color:red;">&amp;nbsp;</span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;btnClearSearch&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;Clear&#8221;</span> <span style="color:red;">CausesValidation</span><span style="color:blue;">=&#8221;false&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;btnSearch&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;Search&#8221;</span> <span style="color:red;">CausesValidation</span><span style="color:blue;">=&#8221;false&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">table</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">p</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">hr</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">p</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">GridView</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;gvCache&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:red;">AutoGenerateColumns</span><span style="color:blue;">=&#8221;false&#8221;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:red;">EmptyDataText</span><span style="color:blue;">=&#8221;No cache data&#8221;&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">Columns</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TemplateField</span> <span style="color:red;">HeaderText</span><span style="color:blue;">=&#8221;Key&#8221;</span> <span style="color:red;">ShowHeader</span><span style="color:blue;">=&#8221;true&#8221;&gt;</span></p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;lblCacheKey&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TemplateField</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TemplateField</span> <span style="color:red;">HeaderText</span><span style="color:blue;">=&#8221;Content&#8221;</span> <span style="color:red;">ShowHeader</span><span style="color:blue;">=&#8221;true&#8221;&gt;</span></p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;lblCacheContent&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TemplateField</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TemplateField</span> <span style="color:red;">HeaderText</span><span style="color:blue;">=&#8221;Tags&#8221;</span> <span style="color:red;">ShowHeader</span><span style="color:blue;">=&#8221;true&#8221;&gt;</span></p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;lblCacheTag&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TemplateField</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">Columns</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">GridView</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">p</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">form</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">html</span><span style="color:blue;">&gt;</span></p>
</div>
<p>The third file is Default3.aspx.cs code-behind:</p>
<p><em><span style="font-style:normal;"><br />
</span></em></p>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;"><span style="color:blue;">using</span> System;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Collections.Generic;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Linq;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Web;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Web.UI;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Web.UI.WebControls;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Text;</p>
<p style="margin:0;"><span style="color:blue;">using</span> Microsoft.Data.Caching;</p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">namespace</span> VelocityTest</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;">[<span style="color:#2b91af;">Serializable</span>]</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">MyCacheItem</span></p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">string</span> Key { <span style="color:blue;">get</span>; <span style="color:blue;">set</span>; }</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">string</span> Content { <span style="color:blue;">get</span>; <span style="color:blue;">set</span>; }</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">DataCacheTag</span>&gt; Tags { <span style="color:blue;">get</span>; <span style="color:blue;">set</span>; }</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> MyCacheItem(<span style="color:blue;">string</span> key, <span style="color:blue;">string</span> conent)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;">Key = key;</p>
<p style="padding-left:90px;margin:0;">Content = conent;</p>
<p style="padding-left:90px;margin:0;">Tags = <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">DataCacheTag</span>&gt;();</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> MyCacheItem(<span style="color:blue;">string</span> key, <span style="color:blue;">string</span> conent, <span style="color:blue;">string</span>[] tags)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;">Key = key;</p>
<p style="padding-left:90px;margin:0;">Content = conent;</p>
<p style="padding-left:90px;margin:0;">Tags = <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">DataCacheTag</span>&gt;();</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">foreach</span> (<span style="color:blue;">string</span> tag <span style="color:blue;">in</span> tags)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;">Tags.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">DataCacheTag</span>(tag));</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">string</span>[] GetTags()</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">string</span>[] tags = <span style="color:blue;">null</span>;</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">if</span> (Tags != <span style="color:blue;">null</span> &amp;&amp; Tags.Count &gt; 0)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;">tags = <span style="color:blue;">new</span> <span style="color:blue;">string</span>[Tags.Count];</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">int</span> i = 0;</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">foreach</span> (<span style="color:#2b91af;">DataCacheTag</span> tag <span style="color:blue;">in</span> Tags)</p>
<p style="padding-left:120px;margin:0;">{</p>
<p style="padding-left:150px;margin:0;">tags[i++] = tag.ToString();</p>
<p style="padding-left:120px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">return</span> tags;</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">enum</span> <span style="color:#2b91af;">TagSearchMethod</span></p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;">NoTag,</p>
<p style="padding-left:60px;margin:0;">AllTags,</p>
<p style="padding-left:60px;margin:0;">AnyTag,</p>
<p style="padding-left:60px;margin:0;">OneTag</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">partial</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">Default3</span> : System.Web.UI.<span style="color:#2b91af;">Page</span></p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">const</span> <span style="color:blue;">string</span> DEFAULT_DELIMITER = <span style="color:#a31515;">&#8220;,&#8221;</span>;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:#2b91af;">DataCacheFactory</span> _factory = <span style="color:#2b91af;">CacheWorker</span>.Instance.CacheFactory;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:#2b91af;">DataCache</span> _cache = <span style="color:#2b91af;">CacheWorker</span>.Instance.DefaultCache;</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">void</span> Page_Load(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;">btnSave.Click += <span style="color:blue;">new</span> <span style="color:#2b91af;">EventHandler</span>(btnSave_Click);</p>
<p style="padding-left:90px;margin:0;">btnCancel.Click += <span style="color:blue;">new</span> <span style="color:#2b91af;">EventHandler</span>(btnCancel_Click);</p>
<p style="padding-left:90px;margin:0;">btnClearSearch.Click += <span style="color:blue;">new</span> <span style="color:#2b91af;">EventHandler</span>(btnClearSearch_Click);</p>
<p style="padding-left:90px;margin:0;">btnSearch.Click += <span style="color:blue;">new</span> <span style="color:#2b91af;">EventHandler</span>(btnSearch_Click);</p>
<p style="padding-left:90px;margin:0;">gvCache.RowDataBound += <span style="color:blue;">new</span> <span style="color:#2b91af;">GridViewRowEventHandler</span>(gvCache_RowDataBound);</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;">gvCache.DataSource = GetCacheDataSource(<span style="color:#2b91af;">TagSearchMethod</span>.NoTag, <span style="color:blue;">null</span>);</p>
<p style="padding-left:90px;margin:0;">gvCache.DataBind();</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">MyCacheItem</span>&gt; GetCacheDataSource(<span style="color:#2b91af;">TagSearchMethod</span> method, <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">DataCacheTag</span>&gt; tags)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">MyCacheItem</span>&gt; items = <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">MyCacheItem</span>&gt;();</p>
<p style="padding-left:90px;margin:0;"><span style="color:#2b91af;">IEnumerable</span>&lt;<span style="color:#2b91af;">KeyValuePair</span>&lt;<span style="color:blue;">string</span>, <span style="color:#2b91af;">Object</span>&gt;&gt; cachePairs = <span style="color:blue;">null</span>;</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">if</span> (method == <span style="color:#2b91af;">TagSearchMethod</span>.NoTag)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;">cachePairs = _cache.GetObjectsInRegion(<span style="color:#2b91af;">CacheWorker</span>.DEFAULT_CACHE_REGION);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">else</span> <span style="color:blue;">if</span> (method == <span style="color:#2b91af;">TagSearchMethod</span>.AllTags)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;">cachePairs = _cache.GetObjectsByAllTags(tags, <span style="color:#2b91af;">CacheWorker</span>.DEFAULT_CACHE_REGION);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">else</span> <span style="color:blue;">if</span> (method == <span style="color:#2b91af;">TagSearchMethod</span>.AnyTag)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;">cachePairs = _cache.GetObjectsByAnyTag(tags, <span style="color:#2b91af;">CacheWorker</span>.DEFAULT_CACHE_REGION);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">else</span> <span style="color:blue;">if</span> (method == <span style="color:#2b91af;">TagSearchMethod</span>.OneTag)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;">cachePairs = _cache.GetObjectsByTag(tags[0], <span style="color:#2b91af;">CacheWorker</span>.DEFAULT_CACHE_REGION);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">if</span> (cachePairs != <span style="color:blue;">null</span>)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">foreach</span> (<span style="color:#2b91af;">KeyValuePair</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">object</span>&gt; item <span style="color:blue;">in</span> cachePairs)</p>
<p style="padding-left:120px;margin:0;">{</p>
<p style="padding-left:150px;margin:0;">items.Add((<span style="color:#2b91af;">MyCacheItem</span>)item.Value);</p>
<p style="padding-left:120px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">return</span> items;</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">void</span> gvCache_RowDataBound(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">GridViewRowEventArgs</span> e)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">if</span> (e.Row.RowType == <span style="color:#2b91af;">DataControlRowType</span>.DataRow)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;"><span style="color:#2b91af;">MyCacheItem</span> data = e.Row.DataItem <span style="color:blue;">as</span> <span style="color:#2b91af;">MyCacheItem</span>;</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">if</span> (data != <span style="color:blue;">null</span>)</p>
<p style="padding-left:120px;margin:0;">{</p>
<p style="padding-left:150px;margin:0;"><span style="color:#2b91af;">Label</span> lblCacheKey = e.Row.FindControl(<span style="color:#a31515;">&#8220;lblCacheKey&#8221;</span>) <span style="color:blue;">as</span> <span style="color:#2b91af;">Label</span>;</p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">if</span> (lblCacheKey != <span style="color:blue;">null</span>)</p>
<p style="padding-left:150px;margin:0;">{</p>
<p style="padding-left:180px;margin:0;">lblCacheKey.Text = data.Key;</p>
<p style="padding-left:150px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;">
<p style="padding-left:150px;margin:0;"><span style="color:#2b91af;">Label</span> lblCacheContent = e.Row.FindControl(<span style="color:#a31515;">&#8220;lblCacheContent&#8221;</span>) <span style="color:blue;">as</span> <span style="color:#2b91af;">Label</span>;</p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">if</span> (lblCacheContent != <span style="color:blue;">null</span>)</p>
<p style="padding-left:150px;margin:0;">{</p>
<p style="padding-left:180px;margin:0;">lblCacheContent.Text = data.Content;</p>
<p style="padding-left:150px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;">
<p style="padding-left:150px;margin:0;"><span style="color:#2b91af;">Label</span> lblCacheTag = e.Row.FindControl(<span style="color:#a31515;">&#8220;lblCacheTag&#8221;</span>) <span style="color:blue;">as</span> <span style="color:#2b91af;">Label</span>;</p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">if</span> (lblCacheTag != <span style="color:blue;">null</span>)</p>
<p style="padding-left:150px;margin:0;">{</p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">if</span> (data.Tags != <span style="color:blue;">null</span>)</p>
<p style="padding-left:180px;margin:0;">{</p>
<p style="padding-left:210px;margin:0;">lblCacheTag.Text = <span style="color:#2b91af;">String</span>.Join(<span style="color:#a31515;">&#8220;,&#8221;</span>, data.GetTags());</p>
<p style="padding-left:180px;margin:0;">}</p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">else</span></p>
<p style="padding-left:180px;margin:0;">{</p>
<p style="padding-left:210px;margin:0;">lblCacheTag.Text = <span style="color:#a31515;">&#8220;&amp;nbsp;&#8221;</span>;</p>
<p style="padding-left:180px;margin:0;">}</p>
<p style="padding-left:150px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">void</span> btnSearch_Click(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">if</span> (radSearchMethodList.SelectedItem != <span style="color:blue;">null</span>)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;"><span style="color:#2b91af;">TagSearchMethod</span> method = (<span style="color:#2b91af;">TagSearchMethod</span>)<span style="color:#2b91af;">Enum</span>.Parse(<span style="color:blue;">typeof</span>(<span style="color:#2b91af;">TagSearchMethod</span>), radSearchMethodList.SelectedValue);</p>
<p style="padding-left:120px;margin:0;"><span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">DataCacheTag</span>&gt; tags = GetTags(txtSearchTag.Text.Trim());</p>
<p style="padding-left:120px;margin:0;">gvCache.DataSource = GetCacheDataSource(method, tags);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">else</span></p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;">gvCache.DataSource = GetCacheDataSource(<span style="color:#2b91af;">TagSearchMethod</span>.NoTag, <span style="color:blue;">null</span>);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;">gvCache.DataBind();</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">void</span> btnClearSearch_Click(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;">Response.Redirect(Request.RawUrl);</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">void</span> btnCancel_Click(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;">Response.Redirect(Request.RawUrl);</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">void</span> btnSave_Click(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">if</span> (!<span style="color:#2b91af;">String</span>.IsNullOrEmpty(txtCacheKey.Text.Trim()) &amp;&amp;</p>
<p style="padding-left:90px;margin:0;">!<span style="color:#2b91af;">String</span>.IsNullOrEmpty(txtCacheContent.Text.Trim()))</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;"><span style="color:#2b91af;">MyCacheItem</span> item = <span style="color:blue;">null</span>;</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">string</span>[] tags = <span style="color:blue;">null</span>;</p>
<p style="padding-left:120px;margin:0;">
<p style="padding-left:120px;margin:0;"><span style="color:blue;">if</span> (!<span style="color:#2b91af;">String</span>.IsNullOrEmpty(txtCacheTag.Text.Trim()))</p>
<p style="padding-left:120px;margin:0;">{</p>
<p style="padding-left:150px;margin:0;">tags = (<span style="color:blue;">string</span>[])txtCacheTag.Text.Trim().Split(DEFAULT_DELIMITER.ToCharArray());</p>
<p style="padding-left:120px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;">
<p style="padding-left:120px;margin:0;"><span style="color:blue;">if</span> (tags != <span style="color:blue;">null</span> &amp;&amp; tags.Length &gt; 0)</p>
<p style="padding-left:120px;margin:0;">{</p>
<p style="padding-left:150px;margin:0;">item = <span style="color:blue;">new</span> <span style="color:#2b91af;">MyCacheItem</span>(txtCacheKey.Text.Trim(), txtCacheContent.Text.Trim(), tags);</p>
<p style="padding-left:120px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">else</span></p>
<p style="padding-left:120px;margin:0;">{</p>
<p style="padding-left:150px;margin:0;">item = <span style="color:blue;">new</span> <span style="color:#2b91af;">MyCacheItem</span>(txtCacheKey.Text.Trim(), txtCacheContent.Text.Trim());</p>
<p style="padding-left:120px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;">
<p style="padding-left:120px;margin:0;">_cache.Put(item.Key, item, item.Tags, <span style="color:#2b91af;">CacheWorker</span>.DEFAULT_CACHE_REGION);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;">gvCache.DataSource = GetCacheDataSource(<span style="color:#2b91af;">TagSearchMethod</span>.NoTag, <span style="color:blue;">null</span>);</p>
<p style="padding-left:90px;margin:0;">gvCache.DataBind();</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">DataCacheTag</span>&gt; GetTags(<span style="color:blue;">string</span> tagString)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">DataCacheTag</span>&gt; tags = <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">DataCacheTag</span>&gt;();</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">string</span>[] items = tagString.Split(DEFAULT_DELIMITER.ToCharArray());</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">foreach</span> (<span style="color:blue;">string</span> item <span style="color:blue;">in</span> items)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;">tags.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">DataCacheTag</span>(item));</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">return</span> tags;</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="margin:0;">}</p>
</div>
<p>The following are screenshots.</p>
<p>This screenshot has nothing is cache.</p>
<p><img class="alignnone size-full wp-image-128" title="ScreenShot001" src="http://atsung.files.wordpress.com/2009/06/screenshot001.jpg?w=479&#038;h=427" alt="ScreenShot001" width="479" height="427" /></p>
<p>This screenshot has 3 cache items.</p>
<p><img class="alignnone size-full wp-image-129" title="ScreenShot002" src="http://atsung.files.wordpress.com/2009/06/screenshot002.jpg?w=479&#038;h=427" alt="ScreenShot002" width="479" height="427" /></p>
<p>This screenshot is search by <strong>AllTags &lt;a&gt;</strong>.</p>
<p><img class="alignnone size-full wp-image-130" title="ScreenShot003" src="http://atsung.files.wordpress.com/2009/06/screenshot003.jpg?w=479&#038;h=427" alt="ScreenShot003" width="479" height="427" /></p>
<p>This screenshot is search by <strong>AllTags &lt;a, b&gt;</strong>.</p>
<p><img class="alignnone size-full wp-image-131" title="ScreenShot004" src="http://atsung.files.wordpress.com/2009/06/screenshot004.jpg?w=479&#038;h=427" alt="ScreenShot004" width="479" height="427" /></p>
<p>This screenshot is search by <strong>AnyTag &lt;a&gt;</strong>.</p>
<p><img class="alignnone size-full wp-image-132" title="ScreenShot005" src="http://atsung.files.wordpress.com/2009/06/screenshot005.jpg?w=479&#038;h=427" alt="ScreenShot005" width="479" height="427" /></p>
<p>This screenshot is search by <strong>AnyTag &lt;b&gt;</strong>.</p>
<p><img class="alignnone size-full wp-image-135" title="ScreenShot006" src="http://atsung.files.wordpress.com/2009/06/screenshot0062.jpg?w=479&#038;h=427" alt="ScreenShot006" width="479" height="427" /></p>
<p>This screenshot is search by <strong>Tag &lt;a, b&gt; &#8211; </strong><span style="color:#ff0000;">there are 4 cache items!</span></p>
<p><img class="alignnone size-full wp-image-136" title="ScreenShot007" src="http://atsung.files.wordpress.com/2009/06/screenshot007.jpg?w=479&#038;h=427" alt="ScreenShot007" width="479" height="427" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=126&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2009/06/01/velocity-ctp3-datacache-getobjectsbyanytag-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>

		<media:content url="http://atsung.files.wordpress.com/2009/06/screenshot001.jpg" medium="image">
			<media:title type="html">ScreenShot001</media:title>
		</media:content>

		<media:content url="http://atsung.files.wordpress.com/2009/06/screenshot002.jpg" medium="image">
			<media:title type="html">ScreenShot002</media:title>
		</media:content>

		<media:content url="http://atsung.files.wordpress.com/2009/06/screenshot003.jpg" medium="image">
			<media:title type="html">ScreenShot003</media:title>
		</media:content>

		<media:content url="http://atsung.files.wordpress.com/2009/06/screenshot004.jpg" medium="image">
			<media:title type="html">ScreenShot004</media:title>
		</media:content>

		<media:content url="http://atsung.files.wordpress.com/2009/06/screenshot005.jpg" medium="image">
			<media:title type="html">ScreenShot005</media:title>
		</media:content>

		<media:content url="http://atsung.files.wordpress.com/2009/06/screenshot0062.jpg" medium="image">
			<media:title type="html">ScreenShot006</media:title>
		</media:content>

		<media:content url="http://atsung.files.wordpress.com/2009/06/screenshot007.jpg" medium="image">
			<media:title type="html">ScreenShot007</media:title>
		</media:content>
	</item>
		<item>
		<title>Velocity (CTP3) &#8211; How do I know if a cache region is created?</title>
		<link>http://atsung.wordpress.com/2009/06/01/velocity-how-do-i-know-if-a-cache-region-is-created/</link>
		<comments>http://atsung.wordpress.com/2009/06/01/velocity-how-do-i-know-if-a-cache-region-is-created/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 00:51:08 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Distribued Cache]]></category>
		<category><![CDATA[Velocity]]></category>
		<category><![CDATA[Cache Region]]></category>
		<category><![CDATA[CTP3]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=118</guid>
		<description><![CDATA[In Velocity (CTP3) we can create, remove, and clean a cache region programmatically by calling the following methods:

DataCache.CreateRegion
DataCache.RemoveRegion
DataCache.ClearRegion

But there is no method to indicate if a cache region is created or not; so if I create a region which has been created already, an exception is thrown with the error code DataCacheErrorCode.RegionAlreadyExsits.
So far the walkaround [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=118&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In Velocity (CTP3) we can create, remove, and clean a cache region programmatically by calling the following methods:</p>
<ul>
<li>DataCache.CreateRegion</li>
<li>DataCache.RemoveRegion</li>
<li>DataCache.ClearRegion</li>
</ul>
<p>But there is no method to indicate if a cache region is created or not; so if I create a region which has been created already, an exception is thrown with the error code DataCacheErrorCode.RegionAlreadyExsits.</p>
<p>So far the walkaround is remove the cache region before creating it:</p>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="padding-left:30px;margin:0;">_defaultCache.RemoveRegion(DEFAULT_CACHE_REGION);</p>
<p style="padding-left:30px;margin:0;">_defaultCache.CreateRegion(DEFAULT_CACHE_REGION, <span style="color:blue;">true</span>);</p>
<p style="padding-left:30px;margin:0;">
</div>
<p>But this is not a good approach; so I hope the Velocity team will add the feature in the next release to check if a cache region is created.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=118&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2009/06/01/velocity-how-do-i-know-if-a-cache-region-is-created/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>
	</item>
		<item>
		<title>Use Velocity (CTP3) as Session State Provider</title>
		<link>http://atsung.wordpress.com/2009/05/22/use-velocity-ctp3-as-session-state-provider/</link>
		<comments>http://atsung.wordpress.com/2009/05/22/use-velocity-ctp3-as-session-state-provider/#comments</comments>
		<pubDate>Fri, 22 May 2009 03:32:03 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Distribued Cache]]></category>
		<category><![CDATA[Session]]></category>
		<category><![CDATA[Velocity]]></category>
		<category><![CDATA[CTP3]]></category>
		<category><![CDATA[Distributed Cache]]></category>
		<category><![CDATA[Session State Provider]]></category>
		<category><![CDATA[web.config]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=114</guid>
		<description><![CDATA[The blog shows how to configure web.config to use Velocity as session state provider, but it only works for CTP2.
I did some experiment and found out the following configuration in web.config will work in Velocity CTP3:

&#60;sessionState mode=&#8220;Custom&#8220; customProvider=&#8220;SessionStoreProvider&#8220;&#62;
 &#60;providers&#62;
 &#60;add name=&#8220;SessionStoreProvider&#8220; type=&#8220;Microsoft.Data.Caching.DataCacheSessionStoreProvider, ClientLibrary&#8220; /&#62;
 &#60;/providers&#62;
 &#60;/sessionState&#62;



       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=114&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The <a href="http://blogs.msdn.com/velocity/archive/2008/10/29/changes-to-session-state-provider-configuration-web-config-for-ctp2.aspx" target="_blank">blog</a> shows how to configure <span style="text-decoration:underline;">web.config</span> to use Velocity as session state provider, but it only works for <strong>CTP2</strong>.</p>
<p>I did some experiment and found out the following configuration in <span style="text-decoration:underline;">web.config</span> will work in Velocity <strong>CTP3</strong>:</p>
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">sessionState</span><span style="color:blue;"> </span><span style="color:red;">mode</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">Custom</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">customProvider</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">SessionStoreProvider</span>&#8220;<span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">providers</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">add</span><span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">SessionStoreProvider</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">type</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">Microsoft.Data.Caching.DataCacheSessionStoreProvider, ClientLibrary</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">providers</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">sessionState</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"><br />
</span></p>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=114&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2009/05/22/use-velocity-ctp3-as-session-state-provider/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>
	</item>
		<item>
		<title>Notification callback in Velocity CTP3</title>
		<link>http://atsung.wordpress.com/2009/05/17/notification-callback-in-velocity-ctp3/</link>
		<comments>http://atsung.wordpress.com/2009/05/17/notification-callback-in-velocity-ctp3/#comments</comments>
		<pubDate>Sun, 17 May 2009 05:14:51 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Distribued Cache]]></category>
		<category><![CDATA[Velocity]]></category>
		<category><![CDATA[AddCacheLevelCallback]]></category>
		<category><![CDATA[Callback]]></category>
		<category><![CDATA[DataCacheOperation]]></category>
		<category><![CDATA[Distributed Cache]]></category>
		<category><![CDATA[Microsoft.Data.Caching]]></category>
		<category><![CDATA[Notification]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=98</guid>
		<description><![CDATA[This is an example of how to make the Notification callback work in Velocity CTP3.
Here is my web.config &#8211; the cache is a routing client:

&#60;?xml version=&#8220;1.0&#8220;?&#62;
&#60;configuration&#62;
 &#60;configSections&#62;

 &#60;!&#8211; required to read the &#60;dataCacheClient&#62; element &#8211;&#62;
 &#60;section name=&#8220;dataCacheClient&#8220;
 type=&#8220;Microsoft.Data.Caching.DataCacheClientSection,CacheBaseLibrary&#8220;
 allowLocation=&#8220;true&#8220;
 allowDefinition=&#8220;Everywhere&#8220;/&#62;

 &#60;!&#8211; required to read the &#60;fabric&#62; element, when present &#8211;&#62;
 &#60;section name=&#8220;fabric&#8220;
 type=&#8220;System.Data.Fabric.Common.ConfigFile,FabricCommon&#8220;
 allowLocation=&#8220;true&#8220;
 allowDefinition=&#8220;Everywhere&#8220;/&#62;


&#60;!&#8211; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=98&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is an example of how to make the Notification callback work in <a href="http://msdn.microsoft.com/en-us/data/cc655792.aspx" target="_blank">Velocity CTP3</a>.</p>
<p>Here is my <span style="text-decoration:underline;">web.config</span> &#8211; the cache is a routing client:</p>
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="margin:0;"><span style="color:blue;">&lt;?</span><span style="color:#a31515;">xml</span><span style="color:blue;"> </span><span style="color:red;">version</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">1.0</span>&#8220;<span style="color:blue;">?&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">configuration</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">configSections</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;!&#8211;</span><span style="color:green;"> required to read the &lt;dataCacheClient&gt; element </span><span style="color:blue;">&#8211;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">section</span><span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">dataCacheClient</span>&#8220;</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> </span><span style="color:red;">type</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">Microsoft.Data.Caching.DataCacheClientSection,CacheBaseLibrary</span>&#8220;</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> </span><span style="color:red;">allowLocation</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8220;</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> </span><span style="color:red;">allowDefinition</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">Everywhere</span>&#8220;<span style="color:blue;">/&gt;</span></p>
<p style="margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;!&#8211;</span><span style="color:green;"> required to read the &lt;fabric&gt; element, when present </span><span style="color:blue;">&#8211;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">section</span><span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">fabric</span>&#8220;</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> </span><span style="color:red;">type</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">System.Data.Fabric.Common.ConfigFile,FabricCommon</span>&#8220;</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> </span><span style="color:red;">allowLocation</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8220;</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> </span><span style="color:red;">allowDefinition</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">Everywhere</span>&#8220;<span style="color:blue;">/&gt;</span></p>
<p style="margin:0;">
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;!&#8211;</span><span style="color:green;"> routing client</span><span style="color:blue;">&#8211;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">dataCacheClient</span><span style="color:blue;"> </span><span style="color:red;">deployment</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">routing</span>&#8220;<span style="color:blue;">&gt;</span></p>
<p style="margin:0;">
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">clientNotification</span><span style="color:blue;"> </span><span style="color:red;">pollInterval</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">300</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
</div>
<p style="margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;!&#8211;</span><span style="color:green;"> cache host(s) </span><span style="color:blue;">&#8211;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">hosts</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">host</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">VIRTUALB-UJT42H</span>&#8220;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;"> </span><span style="color:red;">cachePort</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">22233</span>&#8220;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;"> </span><span style="color:red;">cacheHostName</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">DistributedCacheService</span>&#8220;<span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">hosts</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">dataCacheClient</span><span style="color:blue;">&gt;</span></p>
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">configuration</span><span style="color:blue;">&gt;</span></p>
</div>
</div>
</div>
<p>Here is the cache cluster configuration via the command <span style="text-decoration:underline;">Export-CacheClusterConfig</span>:</p>
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="margin:0;"><span style="color:blue;">&lt;?</span><span style="color:#a31515;">xml</span><span style="color:blue;"> </span><span style="color:red;">version</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">1.0</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">encoding</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">utf-8</span>&#8220;<span style="color:blue;">?&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">configuration</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">configSections</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">section</span><span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">dataCache</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">type</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">Microsoft.Data.Caching.DataCacheSection, CacheBaseLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">configSections</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">dataCache</span><span style="color:blue;"> </span><span style="color:red;">cluster</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">Velocity_Cluster_1</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">size</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">Small</span>&#8220;<span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">caches</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">cache</span><span style="color:blue;"> </span><span style="color:red;">type</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">partitioned</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">consistency</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">strong</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">default</span>&#8220;<span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">policy</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">eviction</span><span style="color:blue;"> </span><span style="color:red;">type</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">lru</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">expiration</span><span style="color:blue;"> </span><span style="color:red;">defaultTTL</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">10</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">isExpirable</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">serverNotification</span><span style="color:blue;"> </span><span style="color:red;">isEnabled</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">policy</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">cache</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">cache</span><span style="color:blue;"> </span><span style="color:red;">type</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">partitioned</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">consistency</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">strong</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">default_2</span>&#8220;<span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">policy</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">eviction</span><span style="color:blue;"> </span><span style="color:red;">type</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">lru</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">expiration</span><span style="color:blue;"> </span><span style="color:red;">defaultTTL</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">10</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">isExpirable</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">serverNotification</span><span style="color:blue;"> </span><span style="color:red;">isEnabled</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">policy</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">cache</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">caches</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">hosts</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">host</span><span style="color:blue;"> </span><span style="color:red;">clusterPort</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">22234</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">hostId</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">1825498580</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">size</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">1024</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">quorumHost</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8220;</p>
<p style="margin:0;"><span style="color:blue;"> </span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">VIRTUALB-UJT42H</span>&#8220;<span style="color:blue;"> </span><span style="color:red;">cacheHostName</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">DistributedCacheService</span>&#8220;</p>
<p style="margin:0;"><span style="color:blue;"> </span><span style="color:red;">cachePort</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">22233</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">hosts</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">advancedProperties</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;</span><span style="color:#a31515;">partitionStoreConnectionSettings</span><span style="color:blue;"> </span><span style="color:red;">providerName</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">System.Data.SqlClient</span>&#8220;</p>
<p style="margin:0;"><span style="color:blue;"> </span><span style="color:red;">connectionString</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">Data Source=VIRTUALB-UJT42H\SQLEXPRESS;Initial Catalog=Velocity_Shared_1;User Id=Not_sa;Password=ForYourEyesOnly;</span>&#8220;</p>
<p style="margin:0;"><span style="color:blue;"> </span><span style="color:red;">leadHostManagement</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">false</span>&#8220;<span style="color:blue;"> /&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">advancedProperties</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;"> &lt;/</span><span style="color:#a31515;">dataCache</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">configuration</span><span style="color:blue;">&gt;</span></p>
</div>
<p>Here is the code of <span style="text-decoration:underline;">CacheWorker.cs</span> (kind of helper class with singleton pattern):</p>
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="margin:0;"><span style="color:blue;">using</span> System;</p>
<p style="margin:0;"><span style="color:blue;">using</span> Microsoft.Data.Caching;</p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">namespace</span> VelocityTest</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">CacheWorker</span></p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:blue;">object</span> _synclock = <span style="color:blue;">new</span> <span style="color:blue;">object</span>();</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">CacheWorker</span> _cacheWorker = <span style="color:blue;">null</span>;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">DataCacheFactory</span> _cacheFactory = <span style="color:blue;">null</span>;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">DataCache</span> _defaultCache = <span style="color:blue;">null</span>;</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">private</span> CacheWorker()</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">CacheWorker</span> Instance</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">get</span></p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;"><span style="color:blue;">lock</span> (_synclock)</p>
<p style="padding-left:120px;margin:0;">{</p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">try</span></p>
<p style="padding-left:150px;margin:0;">{</p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">if</span> (_cacheWorker == <span style="color:blue;">null</span>)</p>
<p style="padding-left:180px;margin:0;">{</p>
<p style="padding-left:210px;margin:0;">_cacheWorker = <span style="color:blue;">new</span> <span style="color:#2b91af;">CacheWorker</span>();</p>
<p style="padding-left:210px;margin:0;">
<p style="padding-left:210px;margin:0;"><span style="color:green;">// we use configuration file</span></p>
<p style="padding-left:210px;margin:0;">_cacheFactory = <span style="color:blue;">new</span> <span style="color:#2b91af;">DataCacheFactory</span>();</p>
<p style="padding-left:210px;margin:0;">
<p style="padding-left:210px;margin:0;"><span style="color:green;">// default cache</span></p>
<p style="padding-left:210px;margin:0;">_defaultCache = _cacheFactory.GetDefaultCache();</p>
<p style="padding-left:180px;margin:0;">}</p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">return</span> _cacheWorker;</p>
<p style="padding-left:150px;margin:0;">}</p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">catch</span> (<span style="color:#2b91af;">DataCacheException</span> ex)</p>
<p style="padding-left:150px;margin:0;">{</p>
<p style="padding-left:180px;margin:0;"><span style="color:blue;">return</span> <span style="color:blue;">null</span>;</p>
<p style="padding-left:150px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:#2b91af;">DataCacheFactory</span> CacheFactory</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">get</span> { <span style="color:blue;">return</span> _cacheFactory; }</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:#2b91af;">DataCache</span> DefaultCache</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">get</span> { <span style="color:blue;">return</span> _defaultCache; }</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="margin:0;">}</p>
</div>
<p>Here is the partial code-behind of the test page:</p>
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">partial</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">_Default</span> : System.Web.UI.<span style="color:#2b91af;">Page</span></p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">const</span> <span style="color:blue;">string</span> CACHE_KEY = <span style="color:#a31515;">&#8220;{8768036E-2B99-4563-8BA5-C2D07B5B6023}&#8221;</span>;</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">DataCacheFactory</span> _factory = <span style="color:#2b91af;">CacheWorker</span>.Instance.CacheFactory;</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">static</span> <span style="color:#2b91af;">DataCache</span> _cache = <span style="color:#2b91af;">CacheWorker</span>.Instance.DefaultCache;</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:30px;margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">void</span> Page_Load(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)</p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">if</span> (!Page.IsPostBack)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:#2b91af;">DataCacheOperation</span> filter = <span style="color:#2b91af;">DataCacheOperation</span>.AddItem | <span style="color:#2b91af;">DataCacheOperation</span>.RemoveItem | <span style="color:#2b91af;">DataCacheOperation</span>.ReplaceItem | <span style="color:#2b91af;">DataCacheOperation</span>.ClearRegion | <span style="color:#2b91af;">DataCacheOperation</span>.CreateRegion | <span style="color:#2b91af;">DataCacheOperation</span>.RemoveRegion;</p>
<p style="padding-left:90px;margin:0;"><span style="color:#2b91af;">DataCacheNotificationDescriptor</span> dn = _cache.AddCacheLevelCallback(filter, OnCacheNotificationReceived);</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;">SetCache(MyPerson, <span style="color:blue;">true</span>);</p>
<p style="padding-left:90px;margin:0;">ShowCache(GetCache());</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;">btnUpdate.Click += <span style="color:blue;">new</span> <span style="color:#2b91af;">EventHandler</span>(btnUpdate_Click);</p>
<p style="padding-left:60px;margin:0;">btnRefresh.Click += <span style="color:blue;">new</span> <span style="color:#2b91af;">EventHandler</span>(btnRefresh_Click);</p>
<p style="padding-left:60px;margin:0;">btnRemove.Click += <span style="color:blue;">new</span> <span style="color:#2b91af;">EventHandler</span>(btnRemove_Click);</p>
<p style="padding-left:60px;margin:0;">btnGet.Click += <span style="color:blue;">new</span> <span style="color:#2b91af;">EventHandler</span>(btnGet_Click);</p>
<p style="padding-left:60px;margin:0;">btnAnotherPage.Click += <span style="color:blue;">new</span> <span style="color:#2b91af;">EventHandler</span>(btnAnotherPage_Click);</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="padding-left:30px;margin:0;"><span style="color:green;">// other code is here&#8230;.</span></p>
<p style="margin:0;"><span style="color:green;"><br />
</span></p>
</div>
</div>
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">void</span> OnCacheNotificationReceived(<span style="color:blue;">string</span> cacheName, <span style="color:blue;">string</span> regionName, <span style="color:blue;">string</span> key, <span style="color:#2b91af;">DataCacheItemVersion</span> version, <span style="color:#2b91af;">DataCacheOperation</span> cacheOperation, <span style="color:#2b91af;">DataCacheNotificationDescriptor</span> nd)</p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;"><span style="color:#2b91af;">StringBuilder</span> sb = <span style="color:blue;">new</span> <span style="color:#2b91af;">StringBuilder</span>();</p>
<p style="padding-left:60px;margin:0;">sb.Append(<span style="color:#a31515;">&#8220;cacheName: &#8220;</span> + cacheName + <span style="color:#2b91af;">Environment</span>.NewLine);</p>
<p style="padding-left:60px;margin:0;">sb.Append(<span style="color:#a31515;">&#8220;regionName: &#8220;</span> + regionName + <span style="color:#2b91af;">Environment</span>.NewLine);</p>
<p style="padding-left:60px;margin:0;">sb.Append(<span style="color:#a31515;">&#8220;key: &#8220;</span> + key + <span style="color:#2b91af;">Environment</span>.NewLine);</p>
<p style="padding-left:60px;margin:0;">sb.Append(<span style="color:#a31515;">&#8220;cacheOperation: &#8220;</span> + cacheOperation.ToString() + <span style="color:#2b91af;">Environment</span>.NewLine);</p>
<p style="padding-left:60px;margin:0;">txtMessageBox.Text = sb.ToString();</p>
<p style="padding-left:30px;margin:0;">}</p>
<div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:9pt;color:black;">
<p style="margin:0;">}</p>
</div>
</div>
<p>Basically the configuration has the Notification enabled and set the client as routing client. The callback is fired when ever there is a change in cache item or region.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=98&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2009/05/17/notification-callback-in-velocity-ctp3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Language ASP.NET Controls</title>
		<link>http://atsung.wordpress.com/2009/04/16/google-language-aspnet-controls/</link>
		<comments>http://atsung.wordpress.com/2009/04/16/google-language-aspnet-controls/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 04:42:11 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Google Code]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CodePlex]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Server Control]]></category>
		<category><![CDATA[Translation]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=92</guid>
		<description><![CDATA[I published my second project at CodePlex &#8211; Google Language ASP.NET Controls.
In my previuos post, I wrote the sample code to create Google Ajax Language Custom Controls &#8211; they are Ajax-able, but this time I just build regular server control to save some time  
The usage is:

Include library:

&#60;%@ Register Assembly="GoogleLanguage.WebControls" Namespace="GoogleLanguage.WebControls" TagPrefix="glc" %&#62;

Bootstrap Javascript [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=92&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I published my second project at CodePlex &#8211; <a href="http://googlelanguage.codeplex.com/" target="_blank">Google Language ASP.NET Controls</a>.</p>
<p>In my <a href="http://atsung.wordpress.com/2008/08/26/google-ajax-language-custom-server-control/" target="_blank">previuos post</a>, I wrote the sample code to create <a href="http://atsung.wordpress.com/2008/08/26/google-ajax-language-custom-server-control/" target="_blank">Google Ajax Language Custom Controls</a> &#8211; they are Ajax-able, but this time I just build regular server control to save some time <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':-)' class='wp-smiley' /> </p>
<p>The usage is:</p>
<ul>
<li>Include library:</li>
</ul>
<pre>&lt;%@ Register Assembly="GoogleLanguage.WebControls" Namespace="GoogleLanguage.WebControls" TagPrefix="glc" %&gt;</pre>
<ul>
<li>Bootstrap Javascript with LanguageManager:</li>
</ul>
<pre>&lt;glc:LanguageManager ID="LanguageManager1" runat="server" /&gt;</pre>
<ul>
<li>Use &lt;Literal&gt; tag for next text:</li>
</ul>
<pre>&lt;glc:Literal ID="Literal5" runat="server" Text="Do you like music too?" DestinationLanguage="FRENCH" /&gt;</pre>
<ul>
<li>Use &lt;Translator&gt; tag for existing text in server controls:</li>
</ul>
<pre>&lt;asp:TextBox ID="TextBox1" runat="server" Text="Important Notice" /&gt;
&lt;glc:Translator ID="Translator2" runat="server" TargetControlID="TextBox1" DestinationLanguage="GERMAN" /&gt;</pre>
<p><strong>Screenshot &#8211; Sample Code</strong></p>
<pre>
<img class="alignnone size-full wp-image-93" title="Sample Code" src="http://atsung.files.wordpress.com/2009/04/google-language-aspnet-controls-sample-code.jpg?w=1024&#038;h=801" alt="Sample Code" width="1024" height="801" /></pre>
<p><strong>Screenshot &#8211; Sample Output</strong></p>
<pre>
<img class="alignnone size-full wp-image-94" title="Sample Output" src="http://atsung.files.wordpress.com/2009/04/google-language-aspnet-controls-sample-website.jpg?w=1024&#038;h=801" alt="Sample Output" width="1024" height="801" /></pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=92&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2009/04/16/google-language-aspnet-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>

		<media:content url="http://atsung.files.wordpress.com/2009/04/google-language-aspnet-controls-sample-code.jpg" medium="image">
			<media:title type="html">Sample Code</media:title>
		</media:content>

		<media:content url="http://atsung.files.wordpress.com/2009/04/google-language-aspnet-controls-sample-website.jpg" medium="image">
			<media:title type="html">Sample Output</media:title>
		</media:content>
	</item>
		<item>
		<title>Expense Tracker</title>
		<link>http://atsung.wordpress.com/2009/04/14/expense-tracker/</link>
		<comments>http://atsung.wordpress.com/2009/04/14/expense-tracker/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 18:00:51 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Expense]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[Tracker]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=88</guid>
		<description><![CDATA[I just publish my first windows application under Microsoft Public License (Ms-PL) &#8211; Expense Tracker &#8211; at CodePlex.com.
The idea of building Expense Tracker is I don&#8217;t want to use Excel spreed sheet to manage my expenses anymore. I have tried different personl finance programs but I found none of them fit my purpose &#8211; I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=88&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I just publish my first windows application under Microsoft Public License (Ms-PL) &#8211; <a href="http://expensetracker.codeplex.com/" target="_blank">Expense Tracker</a> &#8211; at <a href="http://www.codeplex.com/" target="_blank">CodePlex.com</a>.</p>
<p>The idea of building <a href="http://expensetracker.codeplex.com/" target="_blank">Expense Tracker</a> is I don&#8217;t want to use Excel spreed sheet to manage my expenses anymore. I have tried different personl finance programs but I found none of them fit my purpose &#8211; I just need something can allow me to enter the amount, GST and PST on things I purchase (yes, I live in Canada, so tax matters). I even bought QuickBooks for bookkeeping, but it&#8217;s too complicated for me. Anyways, I have to build my own program to manage the expenses.</p>
<p><a href="http://expensetracker.codeplex.com/" target="_blank">Expense Tracker</a> uses SQLite as the database to store data in a file, so any SQLite client tool can open the file and manage the data manually if necessary. I used configuration file to store GST and PST rates based on user&#8217;s residential province, so user can change the settings based on his/her needs. So far I don&#8217;t any plan to make it working outside of Canada <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':-)' class='wp-smiley' /> </p>
<p>Here is the screen shot:</p>
<div id="attachment_89" class="wp-caption alignnone" style="width: 510px"><a href="http://expensetracker.codeplex.com/" target="_blank"><img class="size-full wp-image-89" title="Expense Tracker Screenshot" src="http://atsung.files.wordpress.com/2009/04/3440031697_811085d230.jpg?w=500&#038;h=411" alt="Expense Tracker Screenshot" width="500" height="411" /></a><p class="wp-caption-text">Expense Tracker Screenshot</p></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=88&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2009/04/14/expense-tracker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>

		<media:content url="http://atsung.files.wordpress.com/2009/04/3440031697_811085d230.jpg" medium="image">
			<media:title type="html">Expense Tracker Screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>DotNetNuke Reset Password</title>
		<link>http://atsung.wordpress.com/2008/11/18/dotnetnuke-reset-password/</link>
		<comments>http://atsung.wordpress.com/2008/11/18/dotnetnuke-reset-password/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 21:48:18 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DotNetNuke]]></category>
		<category><![CDATA[Change Password]]></category>
		<category><![CDATA[Generate Password]]></category>
		<category><![CDATA[Get Password]]></category>
		<category><![CDATA[Membership Provider]]></category>
		<category><![CDATA[Reset Password]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=80</guid>
		<description><![CDATA[When I use DotNetNuke.Entities.Users.UserController.ResetPassword(), I assume this method will set the password length to the length I defined in Membership Provider Settings, but which is not the case. So I have to manually create a new password with the minimum password length and change the current password.
Here is the code:

DotNetNuke.Entities.Users.UserInfo userInfo = DotNetNuke.Entities.Users.UserController.GetUserByName(PortalId, UserName);


DotNetNuke.Security.Membership.MembershipProvider membershipProvider [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=80&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>When I use DotNetNuke.Entities.Users.UserController.ResetPassword(), I assume this method will set the password length to the length I defined in Membership Provider Settings, but which is not the case. So I have to manually create a new password with the minimum password length and change the current password.</p>
<p>Here is the code:</p>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;">DotNetNuke.Entities.Users.<span style="color:#2b91af;">UserInfo</span> userInfo = DotNetNuke.Entities.Users.<span style="color:#2b91af;">UserController</span>.GetUserByName(PortalId, UserName);</p>
</div>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;">DotNetNuke.Security.Membership.<span style="color:#2b91af;">MembershipProvider</span> membershipProvider = DotNetNuke.Security.Membership.<span style="color:#2b91af;">MembershipProvider</span>.Instance();</p>
<p style="margin:0;"><span style="color:blue;">if</span> (membershipProvider.PasswordFormat == DotNetNuke.Security.Membership.<span style="color:#2b91af;">PasswordFormat</span>.Encrypted)</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">string</span> oldPassword = DotNetNuke.Entities.Users.<span style="color:#2b91af;">UserController</span>.GetPassword(<span style="color:blue;">ref</span> userInfo, userInfo.Membership.PasswordAnswer);</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">string</span> newPassword = DotNetNuke.Entities.Users.<span style="color:#2b91af;">UserController</span>.GeneratePassword(membershipProvider.MinPasswordLength);</p>
<p style="padding-left:30px;margin:0;">DotNetNuke.Entities.Users.<span style="color:#2b91af;">UserController</span>.ChangePassword(userInfo, oldPassword, newPassword);</p>
<p style="margin:0;">}</p>
<p style="margin:0;"><span style="color:blue;">else</span></p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;">DotNetNuke.Entities.Users.<span style="color:#2b91af;">UserController</span>.ResetPassword(userInfo, userInfo.Membership.PasswordAnswer);</p>
<p style="margin:0;">}</p>
<p style="margin:0;">
<p style="font-family:Courier New;font-size:9pt;color:black;background:white;">
</div>
<p>The method GetPassword() will only return the password if the membership provider supports and is using a password encryption method that supports decryption.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=80&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2008/11/18/dotnetnuke-reset-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>
	</item>
		<item>
		<title>Google AJAX Language Custom Server Control</title>
		<link>http://atsung.wordpress.com/2008/08/26/google-ajax-language-custom-server-control/</link>
		<comments>http://atsung.wordpress.com/2008/08/26/google-ajax-language-custom-server-control/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 03:55:56 +0000</pubDate>
		<dc:creator>atsung</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Google Code]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google AJAX Language]]></category>
		<category><![CDATA[IScriptControl]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Localization]]></category>
		<category><![CDATA[ScriptDescriptor]]></category>
		<category><![CDATA[ScriptManager]]></category>
		<category><![CDATA[ScriptReference]]></category>
		<category><![CDATA[Server Control]]></category>
		<category><![CDATA[Translation]]></category>

		<guid isPermaLink="false">http://atsung.wordpress.com/?p=46</guid>
		<description><![CDATA[I tried Google AJAX Language API yesterday with a &#8220;Hello World&#8221; example, today I build an ASP.NET AJAX-enabled custom server control for it. The coding process is fun and it&#8217;s way simpler than building Virtual Earth Map AJAX-enabled controls at work. If you need to learn how to build an ASP.NET AJAX-enabled custom server control, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=46&subd=atsung&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I tried <a href="http://code.google.com/apis/ajaxlanguage/" target="_blank">Google AJAX Language API</a> yesterday with a <a href="http://atsung.wordpress.com/2008/08/25/google-ajax-language-in-aspnet/" target="_blank">&#8220;Hello World&#8221; example</a>, today I build an ASP.NET AJAX-enabled custom server control for it. The coding process is fun and it&#8217;s way simpler than building Virtual Earth Map AJAX-enabled controls at work. If you need to learn how to build an ASP.NET AJAX-enabled custom server control, this <a href="http://www.asp.net/AJAX/Documentation/Live/tutorials/IScriptControlTutorial1.aspx" target="_blank">tutorial</a> will help you.</p>
<p>My Google AJAX Language custom server control is straightforward and it extends System.Web.UI.WebControls.Label class and implements System.Web.UI.IScriptControl interface. I will list the source code and give some notes.</p>
<p><strong>GoogleLanguageLabel.cs &#8211; server-side code of control<br />
</strong></p>
<ol>
<li>Text property is overridden &#8211; this is the text will be translated to target language based on the LanguageCode property.</li>
<li>LanguageCode property &#8211; See Google <a href="http://code.google.com/apis/ajaxlanguage/documentation/reference.html#LangNameArray" target="_blank">Language Enum</a> for valid codes.</li>
<li>AssemblyInfo.cs and WebResource &#8211; Add the following line to AssemblyInfo.cs because we will make the associated Javascript as web resource: [assembly: System.Web.UI.WebResource("Posts.AjaxControl.GoogleLanguageLabel.js", "application/x-javascript")]</li>
</ol>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;"><span style="color:blue;">using</span> System;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Collections.Generic;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.ComponentModel;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Text;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Web;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Web.UI;</p>
<p style="margin:0;"><span style="color:blue;">using</span> System.Web.UI.WebControls;</p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">namespace</span> Posts.AjaxControl</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;">[<span style="color:#2b91af;">DefaultProperty</span>(<span style="color:#a31515;">"Text"</span>)]</p>
<p style="padding-left:30px;margin:0;">[<span style="color:#2b91af;">ToolboxData</span>(<span style="color:#a31515;">"&lt;{0}:GoogleLanguageLabel runat=server&gt;&lt;/{0}:GoogleLanguageLabel&gt;"</span>)]</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">GoogleLanguageLabel</span> : <span style="color:#2b91af;">Label</span>, <span style="color:#2b91af;">IScriptControl</span></p>
<p style="padding-left:30px;margin:0;">{</p>
<p style="padding-left:60px;margin:0;">[<span style="color:#2b91af;">Category</span>(<span style="color:#a31515;">"Appearance"</span>)]</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">override</span> <span style="color:blue;">string</span> Text</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">get</span> { <span style="color:blue;">return</span> ((ViewState[<span style="color:#a31515;">"Text"</span>] != <span style="color:blue;">null</span>) ? ViewState[<span style="color:#a31515;">"Text"</span>].ToString() : <span style="color:#2b91af;">String</span>.Empty); }</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">set</span> { ViewState[<span style="color:#a31515;">"Text"</span>] = <span style="color:blue;">value</span>; }</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:60px;margin:0;">[<span style="color:#2b91af;">Category</span>(<span style="color:#a31515;">"Appearance"</span>)]</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">public</span> <span style="color:blue;">string</span> LanguageCode</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">get</span> { <span style="color:blue;">return</span> ((ViewState[<span style="color:#a31515;">"LanguageCode"</span>] != <span style="color:blue;">null</span>) ? ViewState[<span style="color:#a31515;">"LanguageCode"</span>].ToString() : <span style="color:#a31515;">&#8220;en&#8221;</span>); }</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">set</span> { ViewState[<span style="color:#a31515;">"LanguageCode"</span>] = <span style="color:blue;">value</span>; }</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">virtual</span> <span style="color:#2b91af;">IEnumerable</span>&lt;<span style="color:#2b91af;">ScriptReference</span>&gt; GetScriptReferences()</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:#2b91af;">ScriptReference</span> reference = <span style="color:blue;">new</span> <span style="color:#2b91af;">ScriptReference</span>(Page.ClientScript.GetWebResourceUrl(<span style="color:blue;">typeof</span>(<span style="color:#2b91af;">GoogleLanguageLabel</span>), <span style="color:#a31515;">&#8220;Posts.AjaxControl.GoogleLanguageLabel.js&#8221;</span>));</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">return</span> <span style="color:blue;">new</span> <span style="color:#2b91af;">ScriptReference</span>[] { reference };</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">virtual</span> <span style="color:#2b91af;">IEnumerable</span>&lt;<span style="color:#2b91af;">ScriptDescriptor</span>&gt; GetScriptDescriptors()</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:#2b91af;">ScriptControlDescriptor</span> descriptor = <span style="color:blue;">new</span> <span style="color:#2b91af;">ScriptControlDescriptor</span>(<span style="color:#a31515;">&#8220;AjaxControl.GoogleLanguageLabel&#8221;</span>, <span style="color:blue;">this</span>.ClientID);</p>
<p style="padding-left:90px;margin:0;">descriptor.AddProperty(<span style="color:#a31515;">&#8220;text&#8221;</span>, <span style="color:blue;">this</span>.Text);</p>
<p style="padding-left:90px;margin:0;">descriptor.AddProperty(<span style="color:#a31515;">&#8220;languageCode&#8221;</span>, <span style="color:blue;">this</span>.LanguageCode);</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">return</span> <span style="color:blue;">new</span> <span style="color:#2b91af;">ScriptDescriptor</span>[] { descriptor };</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:#2b91af;">IEnumerable</span>&lt;<span style="color:#2b91af;">ScriptReference</span>&gt; <span style="color:#2b91af;">IScriptControl</span>.GetScriptReferences()</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">return</span> GetScriptReferences();</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:#2b91af;">IEnumerable</span>&lt;<span style="color:#2b91af;">ScriptDescriptor</span>&gt; <span style="color:#2b91af;">IScriptControl</span>.GetScriptDescriptors()</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">return</span> GetScriptDescriptors();</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> OnPreRender(<span style="color:#2b91af;">EventArgs</span> e)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">if</span> (!<span style="color:blue;">this</span>.DesignMode)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;"><span style="color:green;">// Test for ScriptManager and register if it exists</span></p>
<p style="padding-left:120px;margin:0;"><span style="color:#2b91af;">ScriptManager</span> sm = <span style="color:#2b91af;">ScriptManager</span>.GetCurrent(Page);</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:120px;margin:0;"><span style="color:blue;">if</span> (sm == <span style="color:blue;">null</span>)</p>
<p style="padding-left:120px;margin:0;">{</p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">throw</span> <span style="color:blue;">new</span> <span style="color:#2b91af;">HttpException</span>(<span style="color:#a31515;">&#8220;A ScriptManager control must exist on the current page.&#8221;</span>);</p>
<p style="padding-left:120px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;">sm.RegisterScriptControl(<span style="color:blue;">this</span>);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;">
<p style="padding-left:90px;margin:0;"><span style="color:blue;">base</span>.OnPreRender(e);</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:blue;">protected</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> Render(<span style="color:#2b91af;">HtmlTextWriter</span> writer)</p>
<p style="padding-left:60px;margin:0;">{</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">if</span> (!<span style="color:blue;">this</span>.DesignMode)</p>
<p style="padding-left:90px;margin:0;">{</p>
<p style="padding-left:120px;margin:0;"><span style="color:#2b91af;">ScriptManager</span>.GetCurrent(Page).RegisterScriptDescriptors(<span style="color:blue;">this</span>);</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">base</span>.Render(writer);</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">}</p>
<p style="margin:0;">}</p>
</div>
<p><strong>GoogleLanguageLabel.js &#8211; client-side code of control<br />
</strong></p>
<ol>
<li>Global variable &#8211; I define a global variable &#8220;global_google&#8221; to make sure it&#8217;s hooked up with the &#8220;google&#8221; object from the external Javascript <a href="http://www.google.com/jsapi" target="_blank">http://www.google.com/jsapi</a>, and this global variable can be accessed inside Javascript functions.</li>
<li>Save context &#8211; Remember to save context (&#8221;this._languageCode&#8221; and &#8220;this.get_element()&#8221; in this case) before going inside the inner functions.</li>
</ol>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;">Type.registerNamespace(<span style="color:#a31515;">&#8216;AjaxControl&#8217;</span>);</p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">var</span> global_google = google;</p>
<p style="margin:0;">
<p style="margin:0;">AjaxControl.GoogleLanguageLabel = <span style="color:blue;">function</span>(element)</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;">AjaxControl.GoogleLanguageLabel.initializeBase(<span style="color:blue;">this</span>, [element]);</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:blue;">this</span>._text = <span style="color:blue;">null</span>;</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">this</span>._languageCode = <span style="color:blue;">null</span>;</p>
<p style="margin:0;">}</p>
<p style="margin:0;">
<p style="margin:0;">AjaxControl.GoogleLanguageLabel.prototype =</p>
<p style="margin:0;">{</p>
<p style="padding-left:30px;margin:0;">initialize : <span style="color:blue;">function</span>() {</p>
<p style="padding-left:60px;margin:0;">AjaxControl.GoogleLanguageLabel.callBaseMethod(<span style="color:blue;">this</span>, <span style="color:#a31515;">&#8216;initialize&#8217;</span>);</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:green;">// save context</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">var</span> langugaeCode = <span style="color:blue;">this</span>._languageCode;</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">var</span> element = <span style="color:blue;">this</span>.get_element();</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:green;">// current text</span></p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">var</span> text = <span style="color:blue;">this</span>.get_element().innerHTML;</p>
<p style="padding-left:60px;margin:0;">
<p style="padding-left:60px;margin:0;"><span style="color:green;">// detect and translate</span></p>
<p style="padding-left:60px;margin:0;">global_google.language.detect(text, <span style="color:blue;">function</span>(result) {</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">if</span> (!result.error &amp;&amp; result.language) {</p>
<p style="padding-left:120px;margin:0;">global_google.language.translate(text, result.language, langugaeCode, <span style="color:blue;">function</span>(result) {</p>
<p style="padding-left:150px;margin:0;"><span style="color:blue;">if</span> (result.translation) {</p>
<p style="padding-left:180px;margin:0;">element.innerHTML = result.translation;</p>
<p style="padding-left:150px;margin:0;">}</p>
<p style="padding-left:120px;margin:0;">});</p>
<p style="padding-left:90px;margin:0;">}</p>
<p style="padding-left:60px;margin:0;">});</p>
<p style="padding-left:30px;margin:0;">},</p>
<p style="margin:0;">
<p style="padding-left:30px;margin:0;">dispose : <span style="color:blue;">function</span>() {</p>
<p style="padding-left:60px;margin:0;">AjaxControl.GoogleLanguageLabel.callBaseMethod(<span style="color:blue;">this</span>, <span style="color:#a31515;">&#8216;dispose&#8217;</span>);</p>
<p style="padding-left:30px;margin:0;">},</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:30px;margin:0;"><span style="color:green;">// *** Control properties ***</span></p>
<p style="padding-left:30px;margin:0;">set_text : <span style="color:blue;">function</span>(value) {</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">if</span> (<span style="color:blue;">this</span>._text !== value) {</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">this</span>._text = value;</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">this</span>.raisePropertyChanged(<span style="color:#a31515;">&#8216;text&#8217;</span>);</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">},</p>
<p style="padding-left:30px;margin:0;">get_text : <span style="color:blue;">function</span>() { <span style="color:blue;">return</span> <span style="color:blue;">this</span>._text; },</p>
<p style="padding-left:30px;margin:0;">
<p style="padding-left:30px;margin:0;">set_languageCode : <span style="color:blue;">function</span>(value) {</p>
<p style="padding-left:60px;margin:0;"><span style="color:blue;">if</span> (<span style="color:blue;">this</span>._languageCode !== value) {</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">this</span>._languageCode = value;</p>
<p style="padding-left:90px;margin:0;"><span style="color:blue;">this</span>.raisePropertyChanged(<span style="color:#a31515;">&#8216;languageCode&#8217;</span>);</p>
<p style="padding-left:60px;margin:0;">}</p>
<p style="padding-left:30px;margin:0;">},</p>
<p style="padding-left:30px;margin:0;">get_languageCode : <span style="color:blue;">function</span>() { <span style="color:blue;">return</span> <span style="color:blue;">this</span>._languageCode; }</p>
<p style="margin:0;">}</p>
<p style="margin:0;">
<p style="margin:0;">AjaxControl.GoogleLanguageLabel.registerClass(<span style="color:#a31515;">&#8216;AjaxControl.GoogleLanguageLabel&#8217;</span>, Sys.UI.Control);</p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">if</span> (<span style="color:blue;">typeof</span>(Sys) !== <span style="color:#a31515;">&#8216;undefined&#8217;</span>) Sys.Application.notifyScriptLoaded();</p>
</div>
<p><strong>GoogleLanguageLabel.aspx &#8211; demo page</strong></p>
<ol>
<li>Register web server control &#8211; &lt;%@ Register Namespace=&#8221;Posts.AjaxControl&#8221; Assembly=&#8221;Posts&#8221; TagPrefix=&#8221;ac&#8221; %&gt;</li>
<li>Link to the external Javascript http://www.google.com/jsapi.</li>
<li>Include Google AJAX Lauguage API in the page &#8211; call google.load(&#8221;language&#8221;, &#8220;1&#8243;); to load version 1 of the AJAX Language API.</li>
<li>Create &lt;ac:GoogleLanguageLabel&gt; controls and assign Language Code.</li>
</ol>
<div style="font-family:Courier New;font-size:9pt;color:black;background:white;">
<p style="margin:0;"><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">@</span> <span style="color:#a31515;">Page</span> <span style="color:red;">Language</span><span style="color:blue;">=&#8221;C#&#8221;</span> <span style="color:red;">AutoEventWireup</span><span style="color:blue;">=&#8221;true&#8221;</span> <span style="color:red;">CodeBehind</span><span style="color:blue;">=&#8221;GoogleLanguageLabel.aspx.cs&#8221;</span> <span style="color:red;">Inherits</span><span style="color:blue;">=&#8221;Posts.AjaxControlDemo.GoogleLanguageLabel&#8221;</span> <span style="background:#ffee62;">%&gt;</span></p>
<p style="margin:0;"><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">@</span> <span style="color:#a31515;">Register</span> <span style="color:red;">Namespace</span><span style="color:blue;">=&#8221;Posts.AjaxControl&#8221;</span> <span style="color:red;">Assembly</span><span style="color:blue;">=&#8221;Posts&#8221;</span> <span style="color:red;">TagPrefix</span><span style="color:blue;">=&#8221;ac&#8221;</span> <span style="background:#ffee62;">%&gt;</span></p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">&lt;!</span><span style="color:#a31515;">DOCTYPE</span> <span style="color:red;">html</span> <span style="color:red;">PUBLIC</span> <span style="color:blue;">&#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;</span> <span style="color:blue;">&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</span></p>
<p style="margin:0;">
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">html</span> <span style="color:red;">xmlns</span><span style="color:blue;">=&#8221;http://www.w3.org/1999/xhtml&#8221;</span> <span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">head</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span>Google Language Label<span style="color:blue;">&lt;/</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">script</span> <span style="color:red;">type</span><span style="color:blue;">=&#8221;text/javascript&#8221;</span> <span style="color:red;">src</span><span style="color:blue;">=&#8221;http://www.google.com/jsapi&#8221;&gt;&lt;/</span><span style="color:#a31515;">script</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">script</span> <span style="color:red;">type</span><span style="color:blue;">=&#8221;text/javascript&#8221;&gt;</span></p>
<p style="padding-left:30px;margin:0;">google.load(<span style="color:#a31515;">&#8220;language&#8221;</span>, <span style="color:#a31515;">&#8220;1&#8243;</span>);</p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">script</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">head</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">form</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;form1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">ScriptManager</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;ScriptManager1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">ac</span><span style="color:blue;">:</span><span style="color:#a31515;">GoogleLanguageLabel</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;lblMessage1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;Hello!&#8221;</span> <span style="color:red;">LanguageCode</span><span style="color:blue;">=&#8221;zh-TW&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">br</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">ac</span><span style="color:blue;">:</span><span style="color:#a31515;">GoogleLanguageLabel</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;lblMessage2&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;How are you?&#8221;</span> <span style="color:red;">LanguageCode</span><span style="color:blue;">=&#8221;fr&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">br</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">ac</span><span style="color:blue;">:</span><span style="color:#a31515;">GoogleLanguageLabel</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;lblMessage3&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;Can I borrow 100 dollars from you?&#8221;</span> <span style="color:red;">LanguageCode</span><span style="color:blue;">=&#8221;hi&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">br</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">ac</span><span style="color:blue;">:</span><span style="color:#a31515;">GoogleLanguageLabel</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;lblMessage4&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;Can I return your money when I win the lottery?&#8221;</span> <span style="color:red;">LanguageCode</span><span style="color:blue;">=&#8221;ja&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">br</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">ac</span><span style="color:blue;">:</span><span style="color:#a31515;">GoogleLanguageLabel</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;lblMessage5&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;</span> <span style="color:red;">Text</span><span style="color:blue;">=&#8221;Actually I just find I still have 1000 dollars in my wallet.&#8221;</span> <span style="color:red;">LanguageCode</span><span style="color:blue;">=&#8221;ru&#8221;</span> <span style="color:blue;">/&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;</span></p>
<p style="padding-left:30px;margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">form</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;</span></p>
<p style="margin:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">html</span><span style="color:blue;">&gt;</span></p>
</div>
<p><strong>Here is the result:</strong></p>
<p><span>Hello!</span><br />
<span>Comment vas-tu?</span><br />
<span>उधार लेने से 100 डॉलर कर सकता हूँ ?</span><br />
<span>あなたのお金を返すときに私に勝つの宝くじですか？</span><br />
<span>На самом деле я просто найти Я еще 1000 долларов в моем кошельке.</span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/atsung.wordpress.com/46/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/atsung.wordpress.com/46/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/atsung.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/atsung.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/atsung.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/atsung.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/atsung.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/atsung.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/atsung.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/atsung.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/atsung.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/atsung.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=atsung.wordpress.com&blog=4439908&post=46&subd=atsung&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://atsung.wordpress.com/2008/08/26/google-ajax-language-custom-server-control/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ec703e693a5641f5e97b6387daeb887?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">atsung</media:title>
		</media:content>
	</item>
	</channel>
</rss>