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

<channel>
	<title>Technology Blog by Ash Chuan &#187; Programming</title>
	<atom:link href="http://www.ashchuan.com/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ashchuan.com/blog</link>
	<description>On software, gadgets, programming and blogging</description>
	<lastBuildDate>Thu, 02 Feb 2012 22:47:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How-to Snippet: SQL Server 2005 Internal error. Buffer provided to read column value is too small.</title>
		<link>http://www.ashchuan.com/blog/2011/06/24/how-to-snippet-sql-server-2005-internal-error-buffer-provided-to-read-column-value-is-too-small/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-snippet-sql-server-2005-internal-error-buffer-provided-to-read-column-value-is-too-small</link>
		<comments>http://www.ashchuan.com/blog/2011/06/24/how-to-snippet-sql-server-2005-internal-error-buffer-provided-to-read-column-value-is-too-small/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 22:02:22 +0000</pubDate>
		<dc:creator>ash</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[How-to Guide]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[DBCC CHECKDB]]></category>
		<category><![CDATA[Hotfix]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Internal Error]]></category>
		<category><![CDATA[Service Pack 2]]></category>
		<category><![CDATA[SQL Server 2005]]></category>

		<guid isPermaLink="false">http://www.ashchuan.com/blog/?p=1145</guid>
		<description><![CDATA[Some of you may have come across this error message in SQL Server 2005. SQL Server 2005: &#8220;Internal error. Buffer provided to read column value is too small. Run DBCC CHECKDB to check for any corruption&#8221;. If you run a DBCC CHECKDB, it will return...]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F06%2F24%2Fhow-to-snippet-sql-server-2005-internal-error-buffer-provided-to-read-column-value-is-too-small%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F06%2F24%2Fhow-to-snippet-sql-server-2005-internal-error-buffer-provided-to-read-column-value-is-too-small%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Some of you may have come across this error message in SQL Server 2005.  <em>SQL Server 2005: &#8220;Internal error. Buffer provided to read column value is too small. Run DBCC CHECKDB to check for any corruption&#8221;</em>.  If you run a DBCC CHECKDB, it will return without any errors.</p>
<p><strong>When do you see the error in SQL Server 2005?</strong></p>
<p>When you do a SELECT&#8230;INTO a temporary table.  Example:  SELECT * INTO #mytable FROM dbo.datatable</p>
<p>Note: where #mytable is the temporary table and dbo.datatable is the table in the database you are working on.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-2635249250939971";
/* 300x250, created 10/02/08 */
google_ad_slot = "1990815382";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><strong>How do you resolve the error?</strong></p>
<p>This was issued Microsoft:<br />
This issue has been fixed in the Cumulative update package 2 for SQL Server 2005 Service Pack 2 (http://support.microsoft.com/kb/936305) as part of SQL Hotfix 50001299. Please install the more recent Cumulative update package 4 for SQL Server 2005 Service Pack 2 (http://support.microsoft.com/kb/941450) which contains this fix and more.</p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.ashchuan.com/blog/2011/06/24/how-to-snippet-sql-server-2005-internal-error-buffer-provided-to-read-column-value-is-too-small/')" href="http://www.sphere.com/search?q=sphereit:http://www.ashchuan.com/blog/2011/06/24/how-to-snippet-sql-server-2005-internal-error-buffer-provided-to-read-column-value-is-too-small/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.ashchuan.com/blog/2011/06/24/how-to-snippet-sql-server-2005-internal-error-buffer-provided-to-read-column-value-is-too-small/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOW TO: PIVOT in SQL Server 2005 to produce cross tabulation</title>
		<link>http://www.ashchuan.com/blog/2011/06/08/how-to-pivot-in-sql-server-2005-to-produce-cross-tabulation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-pivot-in-sql-server-2005-to-produce-cross-tabulation</link>
		<comments>http://www.ashchuan.com/blog/2011/06/08/how-to-pivot-in-sql-server-2005-to-produce-cross-tabulation/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 08:38:16 +0000</pubDate>
		<dc:creator>ash</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[How-to Guide]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[cross tabulation]]></category>
		<category><![CDATA[PIVOT]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[Transact SQL]]></category>

		<guid isPermaLink="false">http://www.ashchuan.com/blog/?p=1128</guid>
		<description><![CDATA[There was no easy way to produce a cross tabulation in SQL Server 2000 but in SQL Server 2005, this is achievable using the PIVOT command. Here is a example on how to produce a cross tabulation in SQL Server 2005. In the example below,...]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F06%2F08%2Fhow-to-pivot-in-sql-server-2005-to-produce-cross-tabulation%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F06%2F08%2Fhow-to-pivot-in-sql-server-2005-to-produce-cross-tabulation%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>There was no easy way to produce a cross tabulation in SQL Server 2000 but in SQL Server 2005, this is achievable using the PIVOT command.  Here is a example on how to produce a cross tabulation in SQL Server 2005.</p>
<p>In the example below, the first table, named EventResult contains the results for an athletic competition.  The second table is what we will produce and it&#8217;s the cross tabulation of the EventResult table.</p>
<div id="attachment_1129" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/06/sql_pivot1.png" rel="lightbox[1128]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/06/sql_pivot1-300x147.png" alt="PIVOT SQL Server 2005 to produce cross tabulation" title="sql_pivot1" width="300" height="147" class="size-medium wp-image-1129" /></a><p class="wp-caption-text">Cross tabulation in SQL Server 2005</p></div>
<p>The T-SQL example below shows you how to produce the cross tabulation mentioned earlier using the PIVOT command.</p>
<div id="attachment_1130" class="wp-caption aligncenter" style="width: 309px"><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/06/pivot_tsql.png" rel="lightbox[1128]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/06/pivot_tsql.png" alt="" title="pivot_tsql" width="299" height="230" class="size-full wp-image-1130" /></a><p class="wp-caption-text">T-SQL example using PIVOT command to produce cross tabulation</p></div>
<p>Explanation:  Let&#8217;s start with the sub-query within the T-SQL query.</p>
<p>What is being PIVOT are the values of the Event column, taking each value and making them into columns ([100m], [200m], [800m]) and each pivoted column will contain SUM(Time).</p>
<div id="attachment_1133" class="wp-caption aligncenter" style="width: 228px"><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/06/pivot_tsql_subquery.png" rel="lightbox[1128]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/06/pivot_tsql_subquery.png" alt="PIVOT sub-query" title="pivot_tsql_subquery" width="218" height="167" class="size-full wp-image-1133" /></a><p class="wp-caption-text">Sub-Query showing PIVOT in T-SQL</p></div>
<p><!--adsense--></p>
<p>The SELECT command highlighted in grey shows the result of the pivoted table as Name, [100m], [200m], [800m].</p>
<div id="attachment_1136" class="wp-caption aligncenter" style="width: 309px"><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/06/pivot_tsql_2.png" rel="lightbox[1128]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/06/pivot_tsql_2.png" alt="PIVOT command in T-SQL" title="pivot_tsql_2" width="299" height="230" class="size-full wp-image-1136" /></a><p class="wp-caption-text">SELECT command showing the PIVOT column headers</p></div>
<p>It may look a little confusing at first glance but I suggest that you create the example in SQL Server 2005 and try out the example and you will see the relationship between the EventResult table, the PIVOT table (cross tabulation) and the T-SQL.</p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.ashchuan.com/blog/2011/06/08/how-to-pivot-in-sql-server-2005-to-produce-cross-tabulation/')" href="http://www.sphere.com/search?q=sphereit:http://www.ashchuan.com/blog/2011/06/08/how-to-pivot-in-sql-server-2005-to-produce-cross-tabulation/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.ashchuan.com/blog/2011/06/08/how-to-pivot-in-sql-server-2005-to-produce-cross-tabulation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Guide on Finding Column in a DataRow in C#</title>
		<link>http://www.ashchuan.com/blog/2011/06/02/quick-guide-on-finding-column-in-a-datarow-in-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quick-guide-on-finding-column-in-a-datarow-in-c</link>
		<comments>http://www.ashchuan.com/blog/2011/06/02/quick-guide-on-finding-column-in-a-datarow-in-c/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 19:21:39 +0000</pubDate>
		<dc:creator>ash</dc:creator>
				<category><![CDATA[How-to Guide]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Contains]]></category>
		<category><![CDATA[DataColumn]]></category>
		<category><![CDATA[DataRow]]></category>
		<category><![CDATA[DataSet]]></category>

		<guid isPermaLink="false">http://www.ashchuan.com/blog/?p=1118</guid>
		<description><![CDATA[When working with a DataSet in .NET, you can check if a Data Column contains a certain label. Below is an example I used in my code to check if the column name &#8220;quote_id&#8221; existed. And if existed, assign the data column value to a...]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F06%2F02%2Fquick-guide-on-finding-column-in-a-datarow-in-c%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F06%2F02%2Fquick-guide-on-finding-column-in-a-datarow-in-c%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/03/dot_net_logo.png" rel="lightbox[1118]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/03/dot_net_logo-300x192.png" alt="" title="dot_net_logo" width="300" height="192" class="aligncenter size-medium wp-image-1030" /></a></p>
<p>When working with a DataSet in .NET, you can check if a Data Column contains a certain label.  Below is an example I used in my code to check if the column name &#8220;quote_id&#8221; existed.  And if existed, assign the data column value to a TextBox.</p>
<p><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/06/contains.png" rel="lightbox[1118]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/06/contains-300x77.png" alt="DataRow Column Contains" title="contains" width="300" height="77" class="aligncenter size-medium wp-image-1121" /></a></p>
<p><!--adsense--></p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.ashchuan.com/blog/2011/06/02/quick-guide-on-finding-column-in-a-datarow-in-c/')" href="http://www.sphere.com/search?q=sphereit:http://www.ashchuan.com/blog/2011/06/02/quick-guide-on-finding-column-in-a-datarow-in-c/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.ashchuan.com/blog/2011/06/02/quick-guide-on-finding-column-in-a-datarow-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET Assembly in GAC</title>
		<link>http://www.ashchuan.com/blog/2011/04/06/net-assembly-in-gac/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=net-assembly-in-gac</link>
		<comments>http://www.ashchuan.com/blog/2011/04/06/net-assembly-in-gac/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 21:18:36 +0000</pubDate>
		<dc:creator>ash</dc:creator>
				<category><![CDATA[How-to Guide]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[GAC]]></category>
		<category><![CDATA[Global Assemby Cache]]></category>

		<guid isPermaLink="false">http://www.ashchuan.com/blog/?p=1033</guid>
		<description><![CDATA[Anyone who develops using .NET framework will encounter GAC, Global Assembly Cache. GAC is a shared repository of assemblies (DLL) maintained by the .NET runtime and all shared assemblies must be strongly named. The usual location for a GAC assembly depending on your operating system...]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F04%2F06%2Fnet-assembly-in-gac%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F04%2F06%2Fnet-assembly-in-gac%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Anyone who develops using .NET framework will encounter GAC, Global Assembly Cache.  GAC is a shared repository of assemblies (DLL) maintained by the .NET runtime and all shared assemblies must be strongly named.</p>
<p>The usual location for a GAC assembly depending on your operating system are:</p>
<p>C:\Windows\Assembly<br />
C:\Winnt\Assembly</p>
<p><!--adsense--></p>
<p><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac6.jpg" rel="lightbox[1033]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac6-300x235.jpg" alt="" title="gac6" width="300" height="235" class="aligncenter size-medium wp-image-1034" /></a></p>
<p><strong>Why a shared repository of assemblies?<br />
</strong><br />
Simply to facilitate code reuse instead of duplicating code between applications.</p>
<p><strong>How to install an assembly in GAC?</strong><br />
You can use a utility called gacutil.exe</p>
<p>Installing assembly using gacutil.exe utility:<br />
<em>gacutil -i MyAssembly.dll</em></p>
<p>Uninstalling assembly using gacutil.exe utility<br />
<em>gacutil -i MyAssembly.dll</em></p>
<p>You can copy assemblies from GAC to a different location, i.e. for deploying from a development server to a production server.</p>
<p><strong>How to copy an assembly from GAC?</strong></p>
<p>1. On command prompt, goto the C:\Windows\Assembly directory.</p>
<p><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac1.jpg" rel="lightbox[1033]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac1-300x148.jpg" alt="" title="gac1" width="300" height="148" class="aligncenter size-medium wp-image-1035" /></a></p>
<p><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac2.jpg" rel="lightbox[1033]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac2-300x148.jpg" alt="" title="gac2" width="300" height="148" class="aligncenter size-medium wp-image-1036" /></a></p>
<p>2. Goto GAC_MSIL directory</p>
<p><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac3.jpg" rel="lightbox[1033]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac3-300x148.jpg" alt="" title="gac3" width="300" height="148" class="aligncenter size-medium wp-image-1040" /></a></p>
<p>3. Goto to CrystalDecisions.CrystalReports.Engine directory.  I am using CrystalDecisions.CrystalReports.Engine as an example.  The assembly that you want to copy would be in a different directory.</p>
<p><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac4.jpg" rel="lightbox[1033]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac4-300x148.jpg" alt="" title="gac4" width="300" height="148" class="aligncenter size-medium wp-image-1041" /></a></p>
<p>4. Goto the version directory, e.g. 10.5&#8230;..  Then copy *.dll to c:\ or your location of choice.</p>
<p><a href="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac5.jpg" rel="lightbox[1033]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2011/04/gac5-300x148.jpg" alt="" title="gac5" width="300" height="148" class="aligncenter size-medium wp-image-1042" /></a></p>
<p>And that&#8217;s how you copy an assembly from GAC for deployment.</p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.ashchuan.com/blog/2011/04/06/net-assembly-in-gac/')" href="http://www.sphere.com/search?q=sphereit:http://www.ashchuan.com/blog/2011/04/06/net-assembly-in-gac/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.ashchuan.com/blog/2011/04/06/net-assembly-in-gac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeFile and CodeBehind in .NET: What the heck is the difference?</title>
		<link>http://www.ashchuan.com/blog/2011/03/31/codefile-and-codebehind-in-net-what-the-heck-is-the-difference/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=codefile-and-codebehind-in-net-what-the-heck-is-the-difference</link>
		<comments>http://www.ashchuan.com/blog/2011/03/31/codefile-and-codebehind-in-net-what-the-heck-is-the-difference/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 22:16:16 +0000</pubDate>
		<dc:creator>ash</dc:creator>
				<category><![CDATA[How-to Guide]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.ashchuan.com/blog/?p=1019</guid>
		<description><![CDATA[The Single-File Page and Code-Behind Page Models The Single-File Page Model Example NewPage.aspx declaration &#60;%@ Page Language=&#8221;C#&#8221; %&#62; The Code-Behind Page Model Example NewPage.aspx declaration (.NET Framework 3.5) &#60;%@ Page Language=&#8221;C#&#8221; CodeFile=&#8221;SamplePage.aspx.cs&#8221; Inherits=&#8221;SamplePage&#8221; AutoEventWireup=&#8221;true&#8221; %&#62; NewPage.aspx declaration (.NET Framework 1.1) Difference between CodeFile and CodeBehind...]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F03%2F31%2Fcodefile-and-codebehind-in-net-what-the-heck-is-the-difference%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F03%2F31%2Fcodefile-and-codebehind-in-net-what-the-heck-is-the-difference%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>The Single-File Page and Code-Behind Page Models<br />
</strong></p>
<p><strong>The Single-File Page Model Example<br />
</strong></p>
<p>NewPage.aspx declaration</p>
<p>&lt;%@ Page Language=&#8221;C#&#8221; %&gt;</p>
<p><strong>The Code-Behind Page Model Example<br />
</strong></p>
<p>NewPage.aspx declaration (.NET Framework 3.5)</p>
<p>&lt;%@ Page Language=&#8221;C#&#8221; CodeFile=&#8221;SamplePage.aspx.cs&#8221; Inherits=&#8221;SamplePage&#8221; AutoEventWireup=&#8221;true&#8221; %&gt;</p>
<p>NewPage.aspx declaration (.NET Framework 1.1)</p>
<p><%@ Page Language="C#" CodeBehind="SamplePage.aspx.cs" Inherits="SamplePage" AutoEventWireup="true" %></p>
<p><!--adsense--></p>
<p><strong>Difference between CodeFile and CodeBehind<br />
</strong></p>
<p>ASP.Net 1.1 used CodeBehind, and the code in the file was classed as a separate class.   However in .Net 2.0, Microsoft introduced partial classes and added CodeFile.  CodeFile doesn&#8217;t include the full code-behind class declaration.  Instead this is generated on page compilation.  The page compilation step automatically generates members for each control and these are then fused with the CodeFile&#8217;s partial class.</p>
<p>Have a read about &#8220;So What is it Code Behind or Code File??&#8221; blog article for more information:</p>
<p><a href="http://blog.mjjames.co.uk/2008/02/so-what-is-it-code-behind-or-code-file.html">http://blog.mjjames.co.uk/2008/02/so-what-is-it-code-behind-or-code-file.html</a></p>
<p><strong>My experience using CodeBehind and CodeFile in .NET Framework 3.5</strong></p>
<p>When I upgraded my ASP.NET web application from .NET 1.1 to .NET 2.0 and then to .NET 3.5 using Visual Studio, the upgrade retained<br />
Codebehind in all your ASP.NET pages.  After the upgrade, I added a new button control to the page, I suddenly noticed that my ASP.NET<br />
page was behaving like the &#8220;Single-File Page Model&#8221;.  It&#8217;s when I replaced CodeBehind with Codefile, that my ASP.NET page recognised<br />
that I am asking it to use the Code-Behind page model and not the Single-file page model.</p>
<p>Anyone has other experiences to share about CodeFile and CodeBehind?</p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.ashchuan.com/blog/2011/03/31/codefile-and-codebehind-in-net-what-the-heck-is-the-difference/')" href="http://www.sphere.com/search?q=sphereit:http://www.ashchuan.com/blog/2011/03/31/codefile-and-codebehind-in-net-what-the-heck-is-the-difference/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.ashchuan.com/blog/2011/03/31/codefile-and-codebehind-in-net-what-the-heck-is-the-difference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating indexed views in SQL Server 2005 &#8211; Quick Guide</title>
		<link>http://www.ashchuan.com/blog/2011/01/10/creating-indexed-views-in-sql-server-2005-quick-guide/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-indexed-views-in-sql-server-2005-quick-guide</link>
		<comments>http://www.ashchuan.com/blog/2011/01/10/creating-indexed-views-in-sql-server-2005-quick-guide/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 21:59:26 +0000</pubDate>
		<dc:creator>ash</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[How-to Guide]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Indexed Views]]></category>
		<category><![CDATA[Quick Guide]]></category>
		<category><![CDATA[SQL Server 2005]]></category>

		<guid isPermaLink="false">http://www.ashchuan.com/blog/?p=1006</guid>
		<description><![CDATA[Here&#8217;s a quick guide on how to create indexed views in SQL Server 2005. How do you create indexed views in SQL Server 2005? 1) Create a table in your database, e.g. CREATE TABLE [dbo].[TestTableSC] ( [ID] [INT] NOT NULL, [name] [varchar] (100) NULL, [description]...]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F01%2F10%2Fcreating-indexed-views-in-sql-server-2005-quick-guide%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2011%2F01%2F10%2Fcreating-indexed-views-in-sql-server-2005-quick-guide%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div id="attachment_975" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.ashchuan.com/blog/wp-content/uploads/2010/12/sql2005.jpg" rel="lightbox[1006]"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2010/12/sql2005-300x143.jpg" alt="SQL Server 2005" title="sql2005" width="300" height="143" class="size-medium wp-image-975" /></a><p class="wp-caption-text">SQL Server 2005</p></div>
<p>Here&#8217;s a quick guide on how to create indexed views in SQL Server 2005.</p>
<p><strong>How do you create indexed views in SQL Server 2005?</strong></p>
<p>1) Create a table in your database, e.g.</p>
<p>CREATE TABLE [dbo].[TestTableSC] (<br />
 [ID]  [INT] NOT NULL,<br />
 [name]  [varchar] (100) NULL,<br />
 [description]  [varchar] (255) NULL<br />
)</p>
<p>2) SET ANSI_NULLS, ANSI_WARNINGS ON&#8230;.</p>
<p>SET NUMERIC_ROUNDABORT OFF;<br />
SET ANSI_PADDING,<br />
    ANSI_WARNINGS,<br />
    CONCAT_NULL_YIELDS_NULL,<br />
    ARITHABORT,<br />
    QUOTED_IDENTIFIER,<br />
    ANSI_NULLS ON;<br />
GO<br />
<span id="more-1006"></span></p>
<p>3) In you database create a view WITH SCHEMABINDING, e.g.</p>
<p>CREATE VIEW [dbo].[TestTableSCView] WITH SCHEMABINDING AS<br />
SELECT ID, name, description FROM dbo.TestTableSC</p>
<p>GO</p>
<p>4) Create a CLUSTERED INDEX</p>
<p>CREATE UNIQUE CLUSTERED INDEX TestTableSC_PKey<br />
     ON TestTableSCView(ID)<br />
GO</p>
<p>Here are the Gotchas on creating indexed views in SQL Server 2005</p>
<p>You can only create a SCHEMABINDING view when the base table is in the same database.  If the base table is in a different database or a linked server, you will get an error.</p>
<p>SQL Server does not allow SCHEMABINDING a view to a base table in a different database.</p>
<p>Example:</p>
<p>CREATE VIEW [dbo].[TestTableSCView2] WITH SCHEMABINDING AS<br />
SELECT ID, name, description FROM database1.dbo.TestTableSC</p>
<p>GO</p>
<p>You&#8217;ll get the error:</p>
<p>Cannot schema bind view &#8216;dbo.TestTableSCView2&#8242; because name &#8216;database1.dbo.TestTableSC&#8217; is invalid for schema binding.   Names must be in two-part format and an object cannot reference itself.</p>
<p><!--adsense--></p>
<p>That concludes the quick guide to creating indexed views in SQL Server 2005.</p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.ashchuan.com/blog/2011/01/10/creating-indexed-views-in-sql-server-2005-quick-guide/')" href="http://www.sphere.com/search?q=sphereit:http://www.ashchuan.com/blog/2011/01/10/creating-indexed-views-in-sql-server-2005-quick-guide/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.ashchuan.com/blog/2011/01/10/creating-indexed-views-in-sql-server-2005-quick-guide/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Implement Ajax CollapsiblePanelExtender in ASP.NET page</title>
		<link>http://www.ashchuan.com/blog/2009/05/02/implement-ajax-collapsiblepanelextender-in-aspnet-page/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=implement-ajax-collapsiblepanelextender-in-aspnet-page</link>
		<comments>http://www.ashchuan.com/blog/2009/05/02/implement-ajax-collapsiblepanelextender-in-aspnet-page/#comments</comments>
		<pubDate>Sat, 02 May 2009 23:18:25 +0000</pubDate>
		<dc:creator>ash</dc:creator>
				<category><![CDATA[How-to Guide]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CollapsiblePanelExtender]]></category>

		<guid isPermaLink="false">http://www.ashchuan.com/blog/?p=848</guid>
		<description><![CDATA[It has never been easier to add Ajax controls to ASP.NET using Visual Studio. There are two approaches to implementing Ajax controls in an ASP.NET page. The first approach is to add the control and its properties to the aspx page. The second approach is...]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2009%2F05%2F02%2Fimplement-ajax-collapsiblepanelextender-in-aspnet-page%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2009%2F05%2F02%2Fimplement-ajax-collapsiblepanelextender-in-aspnet-page%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>It has never been easier to add Ajax controls to ASP.NET using Visual Studio.  There are two approaches to implementing Ajax controls in an ASP.NET page.  The first approach is to add the control and its properties to the aspx page.  The second approach is to add the control to the aspx page and then write the code in the code-behind page.  The example which I am going to show you will use the first approach and the Ajax control that I will implement is the <strong>CollapsiblePanelExtender</strong>.  </p>
<p>Here is an example to show you what the CollapsiblePanelExtender will do in your browser.  The CollapsiblePanelExtender will allow you to expand the panel on an ASP.NET page to display its content by clicking the control.  It will not do a server-side post back and the page does not refresh in the browser.  Alternatively you can collapse or hide the content by clicking on the expanded control.<br />
<span id="more-848"></span><br />
<strong>A collapse control</strong></p>
<div align="center">
<a href="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj6.png" rel="lightbox" title="CollapsiblePanelExtender example"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj6_300_127.png" width="300" height="127" alt="Example" /></a>
</div>
<p><strong>An expanded control<br />
</strong></p>
<div align="center">
<a href="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj7.png" rel="lightbox" title="CollapsiblePanelExtender example"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj7_300_128.png" width="300" height="128" alt="Example" /></a>
</div>
<p><strong>Here&#8217;s how we create it in ASP.NET<br />
</strong></p>
<p>1. Add the Ajax <strong>ScriptManager</strong> and <strong>CollapsiblePanelExtender</strong> controls to the aspx page.  You simply drag and drop the controls onto the aspx page in design mode.</p>
<div align="center">
<img src="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj2.png" alt="aj2" title="aj2" class="alignnone size-full wp-image-850" /></div>
<p><strong>Design mode view in the aspx page.<br />
</strong></p>
<div align="center">
<a href="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj5.png" rel="lightbox" title="CollapsiblePanelExtender example"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj5_300_82.png" width="300" height="82" alt="Example" /></a>
</div>
<p><!--adsense--></p>
<p><strong>Code view in the aspx page<br />
</strong></p>
<div align="center">
<a href="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj4.png" rel="lightbox" title="CollapsiblePanelExtender example"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj4_300_162.png" width="300" height="162" alt="Example" /></a>
</div>
<p>You will notice that the <strong>TargetControlID</strong>, <strong>CollapseControlID</strong> and <strong>ExpandControlID</strong> properties refer to <strong>Panel</strong> controls.  That&#8217;s right, we have to add the <strong>Panel</strong> controls as we haven&#8217;t done that earlier.  You add the Panel control the same way as you added the ScriptManager and CollapsiblePanelExtender.</p>
<div align="center">
<a href="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj3.png" rel="lightbox" title="CollapsiblePanelExtender example"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj3_300_181.png" width="300" height="181" alt="Example" /></a>
</div>
<p>Finally, we have to added the css.  You will notice that the Panel controls that we added reference to a <strong>CssClass=CollapsePanelHeader</strong> and <strong>CssClass=CollapsePanel</strong>.  Add the following at the top of the aspx page between the Head tags.</p>
<div align="center">
<img src="http://www.ashchuan.com/blog/wp-content/uploads/2009/05/aj1.png" alt="aj1" title="aj1" class="alignnone size-full wp-image-849" /></div>
<p><strong>Next step:<br />
</strong><br />
Compile your aspx page in Visual Studio and then run the aspx page.</p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.ashchuan.com/blog/2009/05/02/implement-ajax-collapsiblepanelextender-in-aspnet-page/')" href="http://www.sphere.com/search?q=sphereit:http://www.ashchuan.com/blog/2009/05/02/implement-ajax-collapsiblepanelextender-in-aspnet-page/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.ashchuan.com/blog/2009/05/02/implement-ajax-collapsiblepanelextender-in-aspnet-page/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>C# quick example of handling Infinity and NaN</title>
		<link>http://www.ashchuan.com/blog/2009/04/26/c-quick-example-of-handling-infinity-and-nan/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=c-quick-example-of-handling-infinity-and-nan</link>
		<comments>http://www.ashchuan.com/blog/2009/04/26/c-quick-example-of-handling-infinity-and-nan/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 19:30:16 +0000</pubDate>
		<dc:creator>ash</dc:creator>
				<category><![CDATA[How-to Guide]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[NaN]]></category>

		<guid isPermaLink="false">http://www.ashchuan.com/blog/?p=841</guid>
		<description><![CDATA[In C# programming you may come across instances where you have to compute numbers especially division of numbers which will return a NaN (Not a Number) or Infinity, when dividing by zero. You can use two methods to check if a number is NaN of...]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2009%2F04%2F26%2Fc-quick-example-of-handling-infinity-and-nan%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2009%2F04%2F26%2Fc-quick-example-of-handling-infinity-and-nan%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div align="center">
<img src="http://www.ashchuan.com/blog/wp-content/uploads/2009/04/prog.gif" alt="prog" title="prog" class="alignnone size-full wp-image-846" /></div>
<p>In C# programming you may come across instances where you have to compute numbers especially division of numbers which will return a <strong>NaN</strong> (Not a Number) or <strong>Infinity</strong>, when dividing by zero.</p>
<p>You can use two methods to check if a number is NaN of Infinity.  The two methods are <strong>IsNaN</strong> and <strong>IsInfinity</strong>.</p>
<p><strong>Here are the examples:</strong></p>
<p><strong><u>IsNaN</u></strong></p>
<p>if (double.IsNaN(per))<br />
            {<br />
                per = 0.0;<br />
}</p>
<p><strong><u>IsInfinity</u></strong></p>
<p>if (double.IsInfinity(per)) {<br />
                per = 100;<br />
}</p>
<p><!--adsense--></p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.ashchuan.com/blog/2009/04/26/c-quick-example-of-handling-infinity-and-nan/')" href="http://www.sphere.com/search?q=sphereit:http://www.ashchuan.com/blog/2009/04/26/c-quick-example-of-handling-infinity-and-nan/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.ashchuan.com/blog/2009/04/26/c-quick-example-of-handling-infinity-and-nan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using ASP.NET Extenders Part II</title>
		<link>http://www.ashchuan.com/blog/2008/12/10/using-aspnet-extenders-part-ii/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-aspnet-extenders-part-ii</link>
		<comments>http://www.ashchuan.com/blog/2008/12/10/using-aspnet-extenders-part-ii/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 21:06:55 +0000</pubDate>
		<dc:creator>ash</dc:creator>
				<category><![CDATA[How-to Guide]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[PopUpExtender]]></category>

		<guid isPermaLink="false">http://www.ashchuan.com/blog/?p=685</guid>
		<description><![CDATA[In Part I of ASP.NET AJAX Extenders, I talked about ASP.NET AJAX and how ASP.NET AJAX extenders fit into the picture. ASP.NET AJAX extenders are controls that enhance Web UI server controls using AJAX to create an interactive web experience. I also elaborated the point...]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2008%2F12%2F10%2Fusing-aspnet-extenders-part-ii%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2008%2F12%2F10%2Fusing-aspnet-extenders-part-ii%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/ajax_logo.png" alt="" title="ajax_logo" class="alignnone size-medium wp-image-659" /><br />
In <a href="http://www.ashchuan.com/blog/2008/12/01/using-aspnet-ajax-extenders-part-i">Part I of ASP.NET AJAX Extenders</a>, I talked about ASP.NET AJAX and how ASP.NET AJAX extenders fit into the picture.  ASP.NET AJAX extenders are controls that enhance Web UI server controls using AJAX to create an interactive web experience.  I also elaborated the point of interactive web experience by showing the CalendarExtender example.</p>
<p>In Part II of ASP.NET AJAX Extenders, I will continue by showing the PopUpExtender example.  Below is an example of a PopUpExtender.  In the PopUpExtender example, you will see the web page Ajaxified when the magnify image is clicked.  The PopUpExtender will return details about the row item.  This is achieved by a Web Service that we will examine further in the code-behind of the ASP.NET page.  Before we do that, we will first learn how to add a PopUpExtender control to an ASP.NET page.<br />
<span id="more-685"></span></p>
<div align="center">
<a href="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/popupextender.jpg" rel="lightbox" title="PopUpExtender"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/popupextender_small.jpg" width="450" height="98" alt="PopUpExtender Example" border="0" /></a></div>
<p><strong>How to add the PopUpExtender control.</strong></p>
<p>In the Visual Studio design mode, click on the Toolbox to see a list of AJAX controls available. The PopUExtender control is one of the controls in the list below.</p>
<div align="center">
<img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/popupextender1.jpg" alt="" title="popupextender1" class="alignnone size-medium wp-image-691" /></div>
<p>Drag the PopupExtender control onto the ASP.NET page in design mode.  You have to also add a Panel control onto the same ASP.NET page.  Let&#8217;s examine the page.</p>
<p><!--adsense--></p>
<div align="center">
<img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/popupextender3.jpg" alt="" title="popupextender3" class="alignnone size-medium wp-image-695" /></div>
<div align="center">
<a href="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/popuextender5.jpg" rel="lightbox" title="PopUpExtender source"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/popuextender5_small.jpg" width="450" height="129" alt="PopUpExtender source" /></a></div>
<p>The PopUpExtender properties:</p>
<p><em>DynamicServiceMethod=&#8221;GetDynamicContent&#8221;</em><br />
This assigns the Web Service method that will be called when you click on the magnify image.  GetDynamicMethod will contain code that will fetch the data from a database and display it in the yellow panel in browser like the first screenshot above.</p>
<p><em>DynamicContentKey=Databinder.Eval(Container, &#8220;DataItem.name_day&#8221;)<br />
</em><br />
This is the key value that will be used by GetDynamicContent to fetch the data from the database.</p>
<p><em>DynamicControlID=&#8221;Panel1&#8243;<br />
</em><br />
This tells the PopUpExtender control which is the control ID to use when data is fetched.  In this example it is Panel1.</p>
<p><em>TargetControlID=&#8221;Image1&#8243;<br />
</em><br />
This sets the magnify image as the TargetControlID.  When you click on the TargetControlID in the user interface, it fires the DynamicServiceMethod.</p>
<p><em>PopupControlID=&#8221;Panel1&#8243;<br />
</em><br />
The returned data is sent to Panel1.</p>
<p><em>Position=&#8221;Right&#8221;<br />
</em><br />
Position to display the returned data in Panel1.  You can set either to the left or right.  See the first screenshot for example.</p>
<p><strong>Let&#8217;s examine the code-behind</strong></p>
<p>Now that we have gone through the design source, we will examine the code-behind for <em>GetDynamicContent</em>.</p>
<div align="center">
<a href="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/popupextender4.jpg" rel="lightbox" title="PopUpExtender code-behind"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/popupextender4_small.jpg" width="450" height="190" alt="PopupExtender code-behind" border="0" /></a></div>
<p>The code-behind of GetDynamicContent uses System.Web.Services to fetch the data.  The contextKey value is passed into GetDynamicContent and data is fetched and we use StringBuilder to build the string that will be returned back to the PopUpExtender control.  Essentially you can code anything you want in GetDynamicContent.  What I have shown here is just an example.  This concludes Part II of Using ASP.NET Extenders.  </p>
<p>Other related Ajax: <a href="http://www.ashchuan.com/blog/2008/11/01/beginning-ajax-with-visual-studio-2005/">Beginning AJAX with Visual Studio 2005</a></p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.ashchuan.com/blog/2008/12/10/using-aspnet-extenders-part-ii/')" href="http://www.sphere.com/search?q=sphereit:http://www.ashchuan.com/blog/2008/12/10/using-aspnet-extenders-part-ii/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.ashchuan.com/blog/2008/12/10/using-aspnet-extenders-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using ASP.NET AJAX Extenders Part I</title>
		<link>http://www.ashchuan.com/blog/2008/12/01/using-aspnet-ajax-extenders-part-i/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-aspnet-ajax-extenders-part-i</link>
		<comments>http://www.ashchuan.com/blog/2008/12/01/using-aspnet-ajax-extenders-part-i/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 21:40:48 +0000</pubDate>
		<dc:creator>ash</dc:creator>
				<category><![CDATA[How-to Guide]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.NET AJAX]]></category>
		<category><![CDATA[CalendarExtender]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[PopUpExtender]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.ashchuan.com/blog/?p=658</guid>
		<description><![CDATA[AJAX Extenders are great when used in ASP.NET web pages. ASP.NET AJAX Extenders are part of the ASP.NET AJAX Control Toolkit. You can download the ASP.NET AJAX Control Toolkit from here. What is ASP.NET AJAX Control Toolkit? The ASP.NET AJAX Control Toolkit is a shared...]]></description>
			<content:encoded><![CDATA[<!-- sphereit start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2008%2F12%2F01%2Fusing-aspnet-ajax-extenders-part-i%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ashchuan.com%2Fblog%2F2008%2F12%2F01%2Fusing-aspnet-ajax-extenders-part-i%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/ajax_logo.png" alt="" title="ajax_logo" class="alignnone size-medium wp-image-659" />AJAX Extenders are great when used in ASP.NET web pages.  ASP.NET AJAX Extenders are part of the ASP.NET AJAX Control Toolkit.  You can download the ASP.NET AJAX Control Toolkit from <a href="http://www.asp.net/Ajax/ajaxcontroltoolkit/" target="_blank">here</a>.</p>
<p><strong>What is ASP.NET AJAX Control Toolkit?</strong><br />
The ASP.NET AJAX Control Toolkit is a shared source project built on top of the Microsoft ASP.NET AJAX framework.  Microsoft and the ASP.NET AJAX community has made it possible to develop sophisticated AJAX web applications using the AJAX Control Toolkit.<br />
<a href="http://www.ashchuan.com/blog/2008/11/01/beginning-ajax-with-visual-studio-2005/"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/otherajaxpost.gif" alt="Begining AJAX with Visual Studio 2005" title="otherajaxpost" class="alignright size-full wp-image-681" align="right" /></a></p>
<p><strong>How does ASP.NET AJAX Extenders fit into the ASP.NET AJAX picture?<br />
</strong>ASP.NET AJAX extenders are controls that enhance Web UI server controls using AJAX to create an interactive web experience.</p>
<p>Here are two AJAX extender examples to elaborate the point of interactive web experience.</p>
<p>The first example is using the CalendarExtender and the second example is using the PopUpExtender.<br />
<span id="more-658"></span><br />
<strong>CalendarExtender Example</strong></p>
<div align="center"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/cextender5.jpg" alt="" title="cextender5" class="alignnone size-medium wp-image-661" /></div>
<p>In the CalendarExtender example, the idea is to achieve the above.  When a user clicks on the calendar image, the calendar will pop-up.  When a date in the calendar is selected, the textbox will be populated with the selected date.  You see this type of control a lot on air line reservation websites.</p>
<p>To achieve this, we need to add a TextBox control, a Image control and a CalendarExtender control. To validate the controls, we have also added a RequiredValidator and a CompareValidator as a date checker.  In the design view in Visual Studio, the controls will look like this:</p>
<div align="center">
<img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/cextender2.jpg" alt="" title="cextender2" class="alignnone size-medium wp-image-663" /></div>
<p><strong>Adding the CalendarExtender control.<br />
</strong><br />
If you have installed the ASP.NET AJAX Control Toolkit, in the Toolbox in Visual Studio, you will see a list of AJAX controls available.  The CalendarExtender control is one of the controls in the list below.</p>
<div align="center">
<img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/cextender1.jpg" alt="" title="cextender1" class="alignnone size-medium wp-image-665" /></div>
<p><!--adsense--><br />
<strong>Let&#8217;s examine the CalendarExtender code<br />
</strong><br />
<a href="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/cextender3.jpg" rel="lightbox" title="Extender3"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/cextender3_small.jpg" width="450" height="200" alt="CalendarExtender code" /></a></p>
<p>In the CalendarExtender properties from the source code, you will see the following:</p>
<p><em>ID=&#8221;CalendarExtender1&#8243;<br />
runat=&#8221;Server&#8221;<br />
TargetControlID=&#8221;TextBox1&#8243;<br />
Format=&#8221;dd/MM/yyyy&#8221;<br />
PopupButtonID=&#8221;Image1&#8243;<br />
</em></p>
<p>TargetControlID tells the CalendarExtender control that TextBox1 is the target for the value selected from the CalendarExtender control.  In this example I have defined the date format as &#8220;dd/MM/yyyy&#8221; since I am coding in UK date format.</p>
<p>PopupButtonID tells the CalendarExtender control that when Image1 is clicked, the CalendarExtender control should appear/disappear depending on its present state.</p>
<p>You will notice from the source code there is a TextBox control, an Image control and validation controls added.  In order for the CalendarExtender control to work, it requires a TextBox control and an Image control and the validation controls were added simply to make the code more robust.</p>
<p><strong>Let&#8217;s examine the code-behind<br />
</strong><br />
Do you need to add code-behind code in order for the CalendarExtender control to work?  The answer is no but I am showing you that you can tell the CalendarExtender control to display today&#8217;s date whenever the web page is loaded.  So this is an extra.  It requires just a single line of code <em>TextBox1.Text = System.DateTime.Now.ToShortDateString();</em> in Page_Load</p>
<p><a href="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/cextender4.jpg" rel="lightbox" title="code-behind"><img src="http://www.ashchuan.com/blog/wp-content/uploads/2008/12/cextender4_450.jpg" width="450" height="206" alt="code-behind for CalendarExtender control" /></a></p>
<p>Now compile the code and run the example in Visual Studio.  This concludes Part I of Using ASP.NET AJAX Extenders.  In Part II of Using ASP.NET AJAX, we will examine the PopUpExtender Example.</p>
<p>AJAX related post: <a href="http://www.ashchuan.com/blog/2008/11/01/beginning-ajax-with-visual-studio-2005/">Beginning AJAX with Visual Studio 2005</a></p>
<!-- sphereit end --><span style="margin-bottom:40px; border-bottom:none;"><a class="iconsphere" title="Sphere: Related Content" onclick="return Sphere.Widget.search('http://www.ashchuan.com/blog/2008/12/01/using-aspnet-ajax-extenders-part-i/')" href="http://www.sphere.com/search?q=sphereit:http://www.ashchuan.com/blog/2008/12/01/using-aspnet-ajax-extenders-part-i/">Sphere: Related Content</a></span><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.ashchuan.com/blog/2008/12/01/using-aspnet-ajax-extenders-part-i/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

