<?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>Dhaval Upadhyaya</title>
	<atom:link href="http://dhavalupadhyaya.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dhavalupadhyaya.wordpress.com</link>
	<description>Articles on Microsoft Technology</description>
	<lastBuildDate>Fri, 23 Jan 2009 17:05:15 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='dhavalupadhyaya.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/e80e614360aa23ecadbd9171ba4d7290?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Dhaval Upadhyaya</title>
		<link>http://dhavalupadhyaya.wordpress.com</link>
	</image>
			<item>
		<title>URL Remapping in .Net 2.0</title>
		<link>http://dhavalupadhyaya.wordpress.com/2009/01/23/url-remapping-in-net-20/</link>
		<comments>http://dhavalupadhyaya.wordpress.com/2009/01/23/url-remapping-in-net-20/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 17:03:17 +0000</pubDate>
		<dc:creator>Dhaval Upadhyaya</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Remap URL]]></category>
		<category><![CDATA[Remap URL in .net]]></category>
		<category><![CDATA[Remapping URL's in web.config file]]></category>
		<category><![CDATA[URL remap in .net]]></category>
		<category><![CDATA[URL Remapping in .Net 2.0]]></category>
		<category><![CDATA[URL Remmaping]]></category>
		<category><![CDATA[urlMappings]]></category>

		<guid isPermaLink="false">http://dhavalupadhyaya.wordpress.com/?p=134</guid>
		<description><![CDATA[In this article I will walk through a concept for URL Remapping in .Net 2.0
The need for url remapping can arise due to several reasons like
Generating SEO friendly urls
Hiding the actual page or other data from web users.
Control over each and every entry and exits for web requests.
Etc.
.Net 2.0 gives flexibility to define and remap [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=134&subd=dhavalupadhyaya&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong><span style="color:#ff6600;">In this article I will walk through a concept for URL Remapping in .Net 2.0</span></strong></p>
<p>The need for url remapping can arise due to several reasons like<br />
Generating SEO friendly urls<br />
Hiding the actual page or other data from web users.<br />
Control over each and every entry and exits for web requests.<br />
Etc.<br />
.Net 2.0 gives flexibility to define and remap urls in web.config file as well as generating your own Custom URL Remapper HTTP Module.<br />
I will explain the first approach i.e remap urls in web.config in this post and will try to wrap up the second one in my next article with a pretty decent code sample for building Custom URL Remapper HTTP Module.<br />
<strong>Remapping URL&#8217;s in web.config file.</strong><br />
To Map urls .Net provides a section named  urlMappings in web.config file where one can define the collection for their mapped urls.</p>
<pre class="brush: xml;">
&lt;configuration&gt;
&lt;system.web&gt;
 &lt;urlMappings&gt;
  &lt;add url=”~/Home.aspx” mappedUrl=”~/Default.aspx”/&gt;
 &lt;/urlMappings&gt;
&lt;/system.web&gt;
&lt;/configuration&gt;
</pre>
<p>Here whenever the request for Home.aspx will come the .Net engine will search for  urlMappings section in web.config file and server the page that is mapped with it. In the above mention example it will server Default.aspx page.<br />
Limitations: To have more control over the urls, regular expression cannot be used. So it is better to build our own  URL Remapper HTTP Module.<br />
<strong>Live World Scenario:</strong><br />
In case of shopping cart with thousands of product categories and catalogs it is very important to make this page SEO Friendly. Though SEO includes several criteria depending on different robots basic idea of URL remains the same. So by using URL Remapping we can generate SEO friendly URLS that robots can easily search.<br />
Like say for example we are having three products categories viz<br />
CellPhones<br />
Computers<br />
DigitalCameras<br />
We can map all the three categories to a single page that servers the purpose of displaying these products based on the product name<br />
So we map all the three to Product.aspx page like shown in the below section.</p>
<pre class="brush: xml;">
&lt;configuration&gt;
&lt;system.web&gt;
 &lt;urlMappings&gt;
  &lt;clear/&gt;
  &lt;add url=&quot;~/CellPhones.aspx&quot; mappedUrl=&quot;~/Product.aspx&quot;/&gt;
  &lt;add url=&quot;~/Computers.aspx&quot; mappedUrl=&quot;~/Product.aspx&quot;/&gt;
  &lt;add url=&quot;~/DigitalCameras.aspx&quot; mappedUrl=&quot;~/Product.aspx&quot;/&gt;
&lt;/urlMappings&gt;
&lt;/system.web&gt;
&lt;/configuration&gt;
</pre>
<p>Now whenever the request for  CellPhones.aspx,  Computers.aspx or DigitalCameras.aspx comes .Net engine will compile Product.aspx page and will server to the requesting client. In Product.aspx page we can extract the name and make calls to database to get all the products related to the given category.</p>
<p> </p>
<p>To Download code sample<span style="color:#ff6600;"><strong> </strong><a title="URL Remapping Code Sample by Dhaval Upadhyaya" href="http://upadhyayadhaval.googlepages.com/URLRemapping.zip" target="_blank">Click Here </a></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dhavalupadhyaya.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dhavalupadhyaya.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dhavalupadhyaya.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dhavalupadhyaya.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dhavalupadhyaya.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dhavalupadhyaya.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dhavalupadhyaya.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dhavalupadhyaya.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dhavalupadhyaya.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dhavalupadhyaya.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=134&subd=dhavalupadhyaya&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dhavalupadhyaya.wordpress.com/2009/01/23/url-remapping-in-net-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43e17fb661c7183b78a0ff22ace00644?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">dhavalupadhyaya</media:title>
		</media:content>
	</item>
		<item>
		<title>Modify Web Configuration file without restarting asp net worker process (aspnet_wp).</title>
		<link>http://dhavalupadhyaya.wordpress.com/2008/10/19/modify-web-configuration-file-without-restarting-asp-net-worker-process-aspnet_wp/</link>
		<comments>http://dhavalupadhyaya.wordpress.com/2008/10/19/modify-web-configuration-file-without-restarting-asp-net-worker-process-aspnet_wp/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 09:11:02 +0000</pubDate>
		<dc:creator>Dhaval Upadhyaya</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[aspnet_wp]]></category>
		<category><![CDATA[aspnet_wp restart while changing configuration file]]></category>
		<category><![CDATA[aspnet_wp restart while changing web config]]></category>
		<category><![CDATA[aspnet_wp restart while changing web.config]]></category>
		<category><![CDATA[Change configuration file without restarting aspnet_wp]]></category>
		<category><![CDATA[Change web config without restarting aspnet_wp]]></category>
		<category><![CDATA[Change web.config without restarting aspnet_wp]]></category>
		<category><![CDATA[donot restart aspnet_wp]]></category>
		<category><![CDATA[stop restarting aspnet_wp]]></category>

		<guid isPermaLink="false">http://dhavalupadhyaya.wordpress.com/?p=124</guid>
		<description><![CDATA[Modify Web Configuration file without restarting asp net worker process (aspnet_wp).
No one in the world can say that web.config file will remain intact after the deployment. Modifications have to happen to some or the other parameters of the web configuration file like one has to add or remove key value pairs from appsettings section etc…
So [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=124&subd=dhavalupadhyaya&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="color:#ff6600;"><strong>Modify Web Configuration file without restarting asp net worker process (aspnet_wp).</strong></span></p>
<p>No one in the world can say that web.config file will remain intact after the deployment. Modifications have to happen to some or the other parameters of the web configuration file like one has to add or remove key value pairs from appsettings section etc…</p>
<p>So what?<br />
As soon as the webs configuration file is saved the aspnet_wp worker process of that particular web application gets restarted and all the current sessions and data are lost.</p>
<p>This can cause tremendous issues to an organization whose application needs to be up for 24*7.</p>
<p>To recover from such kind of scenario Microsoft has already provided a great tweak to handle this.</p>
<p>Following are some steps that need to be followed.<br />
Step 1) Make a separate configuration file lets say for example appsettings.config with the following xml data.</p>
<pre class="brush: xml;">

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;appSettings&gt;
  &lt;clear/&gt;
  &lt;add key=&quot;Name&quot; value=&quot;Dhaval&quot;/&gt;
  &lt;add key=&quot;Surname&quot; value=&quot;Upadhyaya&quot;/&gt;
&lt;/appSettings&gt;
</pre>
<p>Step 2) Now in the original web.config file make your appSettings section look like below</p>
<pre class="brush: xml;">

&lt;appSettings configSource=&quot;appsettings.config&quot;&gt;
&lt;/appSettings&gt;
</pre>
<p>You are done.</p>
<p> <br />
Place a debug point on the Application_Start event in global.asax file and check that changing appsettings.config does not restart the worker process.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dhavalupadhyaya.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dhavalupadhyaya.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dhavalupadhyaya.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dhavalupadhyaya.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dhavalupadhyaya.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dhavalupadhyaya.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dhavalupadhyaya.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dhavalupadhyaya.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dhavalupadhyaya.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dhavalupadhyaya.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=124&subd=dhavalupadhyaya&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dhavalupadhyaya.wordpress.com/2008/10/19/modify-web-configuration-file-without-restarting-asp-net-worker-process-aspnet_wp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43e17fb661c7183b78a0ff22ace00644?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">dhavalupadhyaya</media:title>
		</media:content>
	</item>
		<item>
		<title>Choosing storage place for Images</title>
		<link>http://dhavalupadhyaya.wordpress.com/2008/10/09/choosing-storage-place-for-images/</link>
		<comments>http://dhavalupadhyaya.wordpress.com/2008/10/09/choosing-storage-place-for-images/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 12:19:57 +0000</pubDate>
		<dc:creator>Dhaval Upadhyaya</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[image storage]]></category>
		<category><![CDATA[storage options for image]]></category>
		<category><![CDATA[Storage options for images]]></category>
		<category><![CDATA[storing image in file system]]></category>
		<category><![CDATA[storing images in database]]></category>
		<category><![CDATA[where to store image]]></category>
		<category><![CDATA[where to store images]]></category>

		<guid isPermaLink="false">http://dhavalupadhyaya.wordpress.com/?p=122</guid>
		<description><![CDATA[   
   
Choosing storage place for Images
 
In this article I have jotted down various pros and cons for choosing the best storage place for images used in our web based applications.
 
There are two basic approaches for storing the images that are used in our web application

File System
Database

 
Below are some comparisons between the two:
  
Ease: One can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=122&subd=dhavalupadhyaya&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><span style="color:#ff6600;"><strong>   </strong></span></span></p>
<p class="MsoNormal" style="margin:0;"><strong><span style="font-size:x-small;color:#ff6600;font-family:Arial;">   </span></strong></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><span style="color:#ff6600;"><strong>Choosing storage place for Images</strong></span></span></p>
<p class="MsoNormal" style="margin:0;"> </p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;">In this article I have jotted down various pros and cons for choosing the best storage place for images used in our web based applications.</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;">There are two basic approaches for storing the images that are used in our web application</span></p>
<ol style="margin-top:0;" type="1">
<li class="MsoNormal"><span style="font-size:10pt;font-family:Arial;">File System</span></li>
<li class="MsoNormal"><span style="font-size:10pt;font-family:Arial;">Database</span></li>
</ol>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;">Below are some comparisons between the two:</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><strong>Ease:</strong> One can easily configure the path of an image from a directory on the web server containing images while from database one needs to create custom logic for reading Image data (eg .ashx handler for image)</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><strong>Flexibility:</strong> It is always easy to store a new image file on the web server while in case of database new column needs to be created. </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><strong>Maintenance:</strong> Using simple file operations for storing the image on web server is very trivial task while in case of database one might need to create a complex query or business logic. </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><strong>Caching:</strong> IIS can be easily configured to cache images stored in file system while images in database needs some further complex IIS configuration</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><strong>Size:</strong> As the web directory in which our application is hosted can be easily scaled in terms of size for storing more images as a when needed while in database the size of database goes on increasing affecting the overall database performance. </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><strong>Compatibility:</strong> Images are stored on file system with basic file operations while in case of database during migration process to some other database vendor their may be some Data Type compatibility problem</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><strong>Performance:</strong> File operations are less costly in resource utilization while database operations are more costly in terms of resources. </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"> </span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dhavalupadhyaya.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dhavalupadhyaya.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dhavalupadhyaya.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dhavalupadhyaya.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dhavalupadhyaya.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dhavalupadhyaya.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dhavalupadhyaya.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dhavalupadhyaya.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dhavalupadhyaya.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dhavalupadhyaya.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=122&subd=dhavalupadhyaya&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dhavalupadhyaya.wordpress.com/2008/10/09/choosing-storage-place-for-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43e17fb661c7183b78a0ff22ace00644?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">dhavalupadhyaya</media:title>
		</media:content>
	</item>
		<item>
		<title>How to create Scheduled Jobs in .net web applications.</title>
		<link>http://dhavalupadhyaya.wordpress.com/2008/08/30/how-to-create-scheduled-jobs-in-net-web-applications/</link>
		<comments>http://dhavalupadhyaya.wordpress.com/2008/08/30/how-to-create-scheduled-jobs-in-net-web-applications/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 09:34:28 +0000</pubDate>
		<dc:creator>Dhaval Upadhyaya</dc:creator>
				<category><![CDATA[Threading]]></category>
		<category><![CDATA[configure scheduled job]]></category>
		<category><![CDATA[Counter parts for scheduler in sql]]></category>
		<category><![CDATA[create schedule in .net]]></category>
		<category><![CDATA[create schedule job in .net]]></category>
		<category><![CDATA[create schedule jobs in .net]]></category>
		<category><![CDATA[create scheduler in .net]]></category>
		<category><![CDATA[how to create job in .net]]></category>
		<category><![CDATA[how to create scheduled job in .net]]></category>
		<category><![CDATA[how to create scheduler in .net]]></category>
		<category><![CDATA[job function in .net]]></category>
		<category><![CDATA[job in .net]]></category>
		<category><![CDATA[scheduled function in .net]]></category>
		<category><![CDATA[Scheduled job in .net]]></category>
		<category><![CDATA[Scheduled jobs]]></category>
		<category><![CDATA[scheduler in .net]]></category>
		<category><![CDATA[scheduling in .net]]></category>
		<category><![CDATA[Timer example in .net]]></category>
		<category><![CDATA[TimerCallback example in .net]]></category>
		<category><![CDATA[TimerCallback function example in .net]]></category>

		<guid isPermaLink="false">http://dhavalupadhyaya.wordpress.com/?p=104</guid>
		<description><![CDATA[How to create Scheduled Jobs in .net web applications.
Calling a function at predefined iteration of time has been one of the key requirements of web applications.
Example:
You want to automatically archive the data.
You want to automatically purge the data.
You want to automatically send the News Letters.
You want to take backup of the files or database etc.
Generally [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=104&subd=dhavalupadhyaya&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong><span style="color:#ff6600;">How to create Scheduled Jobs in .net web applications.</span></strong></p>
<p>Calling a function at predefined iteration of time has been one of the key requirements of web applications.<br />
Example:<br />
You want to automatically archive the data.<br />
You want to automatically purge the data.<br />
You want to automatically send the News Letters.<br />
You want to take backup of the files or database etc.</p>
<p>Generally this type of functionality can be easily archived by creating and configuring scheduled jobs in SQL Server.</p>
<p>What if you are using the express edition of SQL Server?<br />
You cannot take advantage of this feature because all the editions of SQL Server do not provide this functionality.</p>
<p>In this article I will explain how we can achieve this functionality using purely .Net framework class.</p>
<p>First of all let’s thanks System.Threading class. The main cream lies inside this class shipped in .Net Framework. Many of us usually do not use it but believe me its one of the most beautiful classes of the framework.</p>
<p>Anyways</p>
<p>Following are the steps which you need to perform:</p>
<p><strong>Step 1)</strong> Create a class called Jobs.cs</p>
<pre class="brush: csharp;">

namespace myScheduler
{
    public sealed class Jobs
    {
        public Jobs(){}

        public static void DailyJob(object state)
        {
           //Your dream goes here.
        }

        public static void HourlyJob(object state)
        {
            //Your dream goes here.
        }
    }
}
</pre>
<p>Jobs class includes the below two functions that will be called by our scheduler which we will create in the second step.<br />
I have created two functions for this purpose.<br />
DailyJob: Will be called daily by the scheduler.<br />
HourlyJob: Will be called hourly by the scheduler.</p>
<p> </p>
<p><strong>Step 2)</strong> Create a class called Scheduler.cs</p>
<pre class="brush: csharp;">

using System;
using System.Threading;

namespace myScheduler
{
    public sealed class Scheduler
    {
        public Scheduler() { }

        public void Scheduler_Start()
        {
            TimerCallback callbackDaily = new TimerCallback(Jobs.DailyJob);
            Timer dailyTimer = new Timer(callbackDaily, null, TimeSpan.Zero, TimeSpan.FromHours(24.0));

            TimerCallback callbackHourly = new TimerCallback(Jobs.HourlyJob);
            Timer hourlyTimer = new Timer(callbackHourly, null, TimeSpan.Zero, TimeSpan.FromHours(1.0));
        }
    }
}
</pre>
<p>Scheduler class contains the actual mechanism for running jobs created in Jobs class in Step one.</p>
<p><span style="text-decoration:underline;">Timer:</span> Mechanism for executing method at specified time intervals. This method has 5 overloads which we can use as per our needs. Some of its parameters are<br />
<span style="text-decoration:underline;">TimerCallback:</span> Represents the method that you want to actually callback on at a particular interval of time.<br />
<span style="text-decoration:underline;">State:</span> Any type of object you want to pass to your callback method.<br />
<span style="text-decoration:underline;">Due Time:</span> Amount of delay after which callback will be invoked. TimeSpan.Zero means immediately.<br />
<span style="text-decoration:underline;">Period:</span> Time period between invocations of callback function.</p>
<p> </p>
<p><strong>Step 3)</strong> Add Global.asax file to your web project. In Application_Start event instantiate Scheduler object and make a call to Scheduler_Start() method.</p>
<pre class="brush: xml;">

&lt;%@ Application Language=&quot;C#&quot; %&gt;
&lt;%@ Import Namespace=&quot;myScheduler&quot; %&gt;

&lt;script RunAt=&quot;server&quot;&gt;

    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        Scheduler objmyScheduler = new Scheduler();
        objmyScheduler.Scheduler_Start();
    }

    void Application_End(object sender, EventArgs e)
    {
        //  Code that runs on application shutdown
    }

    void Application_Error(object sender, EventArgs e)
    {
        // Code that runs when an unhandled error occurs
    }

    void Session_Start(object sender, EventArgs e)
    {
        // Code that runs when a new session is started
    }

    void Session_End(object sender, EventArgs e)
    {
        // Code that runs when a session ends.
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer
        // or SQLServer, the event is not raised.

    }
      
&lt;/script&gt;
</pre>
<p> </p>
<p>You are done.</p>
<p>How it works?<br />
Whenever the applications is first started the  Application_Start() in Global.asax is called and this calls Scheduler_Start() method which configures all the Jobs that we have created.</p>
<p>I have demonstrated a daily and hourly job in the above examples. In order to debug and test this code you need to wait for an Hour or a Day. Don’t panic I have done this intentionally. So in order to brush up your above learning’s prepare a job in Jobs.cs file that would be called every minute. Configure the callback and timer for your new job in Scheduler.cs file and enjoy the gist of scheduling.</p>
<p><strong>Note:</strong> After running the project once do not forget to restart the IIS because Application_Start() wont be called every time you run your project. You know why?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dhavalupadhyaya.wordpress.com/104/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dhavalupadhyaya.wordpress.com/104/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dhavalupadhyaya.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dhavalupadhyaya.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dhavalupadhyaya.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dhavalupadhyaya.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dhavalupadhyaya.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dhavalupadhyaya.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dhavalupadhyaya.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dhavalupadhyaya.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dhavalupadhyaya.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dhavalupadhyaya.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=104&subd=dhavalupadhyaya&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dhavalupadhyaya.wordpress.com/2008/08/30/how-to-create-scheduled-jobs-in-net-web-applications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43e17fb661c7183b78a0ff22ace00644?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">dhavalupadhyaya</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Encrypt or Decrypt sections of Configuration file.</title>
		<link>http://dhavalupadhyaya.wordpress.com/2008/08/15/encryptingdecrypting-sections-of-configuration-file/</link>
		<comments>http://dhavalupadhyaya.wordpress.com/2008/08/15/encryptingdecrypting-sections-of-configuration-file/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 13:08:49 +0000</pubDate>
		<dc:creator>Dhaval Upadhyaya</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[decrypt appsettings]]></category>
		<category><![CDATA[decrypt config file]]></category>
		<category><![CDATA[decrypt connectionstring]]></category>
		<category><![CDATA[decrypt sections of configuration file]]></category>
		<category><![CDATA[decrypt sections of web config]]></category>
		<category><![CDATA[encrypt appsettings]]></category>
		<category><![CDATA[encrypt config file]]></category>
		<category><![CDATA[encrypt connectionstring]]></category>
		<category><![CDATA[Encrypt Decrypt web.config]]></category>
		<category><![CDATA[encrypt section in web.config]]></category>
		<category><![CDATA[encrypt sections of configuration file]]></category>
		<category><![CDATA[encrypt sections of web config]]></category>
		<category><![CDATA[encrypt web.config]]></category>
		<category><![CDATA[Encrypting\Decrypting sections of Configuration file]]></category>
		<category><![CDATA[how to encrypt appSettings section]]></category>
		<category><![CDATA[how to encrypt connectionStrings]]></category>
		<category><![CDATA[how to encrypt decrypt connection string section]]></category>
		<category><![CDATA[how to encrypt decrypt web.config]]></category>

		<guid isPermaLink="false">http://dhavalupadhyaya.wordpress.com/?p=93</guid>
		<description><![CDATA[How to Encrypt or Decrypt sections of Configuration file.
It is always a good practice to protect sensitive information in configuration files. One should always protect connectionStrings section from being easily readable; also some times it becomes necessary to encrypt appSettings section that may include some sensitive data. You know why…?
So in this Blog I will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=93&subd=dhavalupadhyaya&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="color:#ff6600;"><strong>How to Encrypt or Decrypt sections of Configuration file.</strong></span></p>
<p>It is always a good practice to protect sensitive information in configuration files. One should always protect connectionStrings section from being easily readable; also some times it becomes necessary to encrypt appSettings section that may include some sensitive data. You know why…?</p>
<p>So in this Blog I will walkthrough the steps required for encryption\decryption of sections in configuration file.</p>
<p>.Net framework ships two providers for this purpose.<br />
RsaProtectedConfigurationProvider and DpapiProtectedConfigurationProvider.<br />
Here I will use RsaProtectedConfigurationProvider.</p>
<p> <br />
<strong>Step 1)</strong> First off all we will add provider to configuration section of web.config file that you want to play with. This provider is required for actual processing done while running commands depicted in step 3 and 4.</p>
<pre class="brush: xml;">

&lt;configuration&gt;
&lt;configProtectedData defaultProvider=&quot;myProvider&quot;&gt;
&lt;providers&gt;
 &lt;clear/&gt;
  &lt;add name=&quot;myProvider&quot;
  type=&quot;System.Configuration.RsaProtectedConfigurationProvider&quot;
  keyContainerName=&quot;NetFrameworkConfigurationKey&quot;/&gt;
&lt;/providers&gt;
&lt;/configProtectedData&gt;
&lt;/configuration&gt;
</pre>
<p> RsaProtectedConfigurationProvider requires key container for encryption and decryption purpose. This container includes private\public keys that are required during encryption and decryption process by the attached provider.</p>
<p>NetFrameworkConfigurationKey : This is the default key container shipped by Microsoft. You can also create your own key container that includes private\public keys required for encryption\decryption. In order to avoid confusion I will depict these steps in my next article.</p>
<p><span style="text-decoration:underline;">Note</span>: As we are using default key container &#8220;NetFrameworkConfigurationKey&#8221; you can do away with the first step. This step will be added by machine.config file cause it includes declaration for both providers  (&#8220;RsaProtectedConfigurationProvider&#8221; and &#8220;DpapiProtectedConfigurationProvider&#8221;). But this will be helpful incase we are creating our own key container.</p>
<p><strong></strong></p>
<p><strong>Step 2)</strong> After adding the provider in Step 1 go to the Visual Studio command prompt. Now In order to access &#8220;NetFrameworkConfigurationKey&#8221; key container your &#8220;ASPNET&#8221; account must have permission to access it. Run the below command to give access.</p>
<p>aspnet_regiis -pa &#8220;NetFrameworkConfigurationKey&#8221; &#8220;ASPNET&#8221;</p>
<p> </p>
<p><strong>Step 3)</strong> Run below command to encrypt connectionStrings section of your web.config file located in the virtual directory named &#8220;MyWebApplication&#8221;.</p>
<p>aspnet_regiis -pe connectionStrings -app /MyWebApplication</p>
<p> </p>
<p><strong>Step 4)</strong> Run below command to decrypt connectionStrings section of your web.config file located in the virtual directory named &#8220;MyWebApplication&#8221;.</p>
<p>aspnet_regiis -pd connectionStrings -app /MyWebApplication</p>
<p><span style="text-decoration:underline;">Note:</span> You can replace the &#8220;connectionStrings&#8221; section with the section name you want to encrypt\decrypt.<br />
Eg: aspnet_regiis -pe appSettings -app /MyWebApplication<br />
This will encrypt &#8220;appSettings&#8221; section of your web.config file located in the virtual directory named &#8220;MyWebApplication&#8221;.</p>
<p>To get more help about aspnet_regiis use the below command<br />
aspnet_regiis help</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dhavalupadhyaya.wordpress.com/93/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dhavalupadhyaya.wordpress.com/93/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dhavalupadhyaya.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dhavalupadhyaya.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dhavalupadhyaya.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dhavalupadhyaya.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dhavalupadhyaya.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dhavalupadhyaya.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dhavalupadhyaya.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dhavalupadhyaya.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dhavalupadhyaya.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dhavalupadhyaya.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=93&subd=dhavalupadhyaya&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dhavalupadhyaya.wordpress.com/2008/08/15/encryptingdecrypting-sections-of-configuration-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43e17fb661c7183b78a0ff22ace00644?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">dhavalupadhyaya</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating Custom Controls in ASP .Net</title>
		<link>http://dhavalupadhyaya.wordpress.com/2008/07/20/creating-custom-controls-in-asp-net/</link>
		<comments>http://dhavalupadhyaya.wordpress.com/2008/07/20/creating-custom-controls-in-asp-net/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 06:55:44 +0000</pubDate>
		<dc:creator>Dhaval Upadhyaya</dc:creator>
				<category><![CDATA[Custom Controls]]></category>
		<category><![CDATA[add web control to toolbox]]></category>
		<category><![CDATA[button in custom control asp.net]]></category>
		<category><![CDATA[Control Class Library]]></category>
		<category><![CDATA[create custum control asp.net]]></category>
		<category><![CDATA[creating a control]]></category>
		<category><![CDATA[creating a custom control]]></category>
		<category><![CDATA[Custom Control in .net]]></category>
		<category><![CDATA[custom control with toolbox image]]></category>
		<category><![CDATA[Custom Controls in .net]]></category>
		<category><![CDATA[Designer for custom control]]></category>
		<category><![CDATA[Desing time attributes]]></category>
		<category><![CDATA[example of custom controls in .net]]></category>
		<category><![CDATA[How to add custom control to toolbox]]></category>
		<category><![CDATA[How to add web control to toolbox]]></category>
		<category><![CDATA[process to create custom controls in asp]]></category>
		<category><![CDATA[Web Controls]]></category>
		<category><![CDATA[WebControls]]></category>
		<category><![CDATA[why create custom controls]]></category>

		<guid isPermaLink="false">http://dhavalupadhyaya.wordpress.com/?p=60</guid>
		<description><![CDATA[Creating Custom Controls in ASP .Net
In this article I have simply demonstrated 2 code examples for creating Custom Web Controls.
Why Custom Controls?
To cater through the real world scenarios that may not be supplemented by inbuilt .Net controls, the need for Custom Control arises. Also their are several other reasons for creating custom control like reusability, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=60&subd=dhavalupadhyaya&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Creating Custom Controls in ASP .Net</strong></p>
<p>In this article I have simply demonstrated 2 code examples for creating Custom Web Controls.</p>
<p><strong>Why Custom Controls?</strong><br />
To cater through the real world scenarios that may not be supplemented by inbuilt .Net controls, the need for Custom Control arises. Also their are several other reasons for creating custom control like reusability, centralized management over the control, ease of usage etc.</p>
<p><strong>How to approach the requirement for creating Custom Controls?</strong><br />
If any of the inbuilt .Net control meets your requirement than you should always use these controls. If not than ask yourself a question</p>
<p>Would any of the existing control help me?</p>
<p>If yes than<br />
Inherit from the existing control and add the new features to it and extend it further.<br />
If No than<br />
You need to build the control from scratch. In this case inherit from WebControl class.</p>
<p><strong></strong> </p>
<p><strong>How to create Custom Controls?</strong></p>
<p>Their are two ways in which you can create a custom control.<br />
1) You can inherit from existing .net web control to extend its features further. OR<br />
2) You can directly inherit from WebControl class to create a web control from scratch.</p>
<p>Depending upon the approach you choose their will be several properties and methods for you to override. All of them cannot be explained here so I am explaining some important among them that I have used in my code samples.</p>
<p>AddAttributesToRender &#8211; Adds HTML or Style attributes for any of your HtmlTextWriterTag. You can also use HtmlTextWriter&#8217;s &#8220;AddAttribute&#8221; , &#8220;AddStyleAttribute&#8221; methods to achieve the same functionality. Make sure that you add this attributes before using &#8220;RenderBeginTag&#8221; method.</p>
<p>RenderContents &#8211; Outputs HTML content of Server Control to HtmlTextWriter object. So override this method to manage the HTML that your custom control renders to the browser.</p>
<p>TagKey &#8211; WebControl renders a span <span>TAG by default on the cient browser. But to render any specific TAG you need to override this method.</span></p>
<p><strong>Inheriting from the existing control<br />
</strong>This example depicts the creation of a new web control named &#8220;myButton&#8221; that is derived from the Button class. It has all the features that a normal button control has. But for a twist I have added a simple feature that prompts for a message before submitting the page back to the server. I have added a new property called &#8220;AlertMessage&#8221; to quench this requirement.</p>
<pre class="brush: csharp;">

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace myControlLib
{
    public class myButton : Button
    {
        public myButton() { }
        private string _AlertMessage = &quot;Are you sure to process this request!&quot;;
        public string AlertMessage
        {
            set { _AlertMessage = value; }
            get { return _AlertMessage; }
        }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, &quot;return confirm('&quot; + _AlertMessage + &quot;')&quot;); base.AddAttributesToRender(writer);
        }
    }
}
</pre>
<p>Registering the control on the web page</p>
<pre class="brush: xml;">

&lt;%@ Register Assembly=&quot;myControlLib&quot; Namespace=&quot;myControlLib&quot; TagPrefix=&quot;myUcl&quot; %&gt;
</pre>
<p>Using the control</p>
<pre class="brush: xml;">

&lt;myUcl:myButton ID=&quot;MyButton1&quot; runat=&quot;server&quot; Text=&quot;MyButton 1&quot;  AlertMessage=&quot;Custom Message here!&quot;/&gt;

&lt;myUcl:myButton ID=&quot;MyButton2&quot; runat=&quot;server&quot; Text=&quot;MyButton 2&quot; /&gt;
</pre>
<p><strong></strong></p>
<p><strong></strong></p>
<p><strong>Inheriting from the WebControl class<br />
</strong>This example depicts the creation of a new web control named &#8220;myImage&#8221; that is directly derived from the WebControl class. This control renders a Picture, Name of the Picture and Description of the Picture. Description of the Picture is displayed when the mouse is moved over the picture.<br />
For this I have created 3 additional properties for this.</p>
<p>ImageUrl &#8211; The url of the image to be displayed</p>
<p>ImageName &#8211; The name of the image.</p>
<p>ImageDescription &#8211; The description for the image.</p>
<pre class="brush: csharp;">

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace myControlLib
{
    public class myImage : WebControl
    {
        public myImage() { }

        private string _ImageUrl = &quot;&quot;;
        public string ImageUrl
        {
            get { return _ImageUrl; }
            set { _ImageUrl = value; }
        }
        private string _ImageName = &quot;&quot;;
        public string ImageName
        {
            get { return _ImageName; }
            set { _ImageName = value; }
        }
        private string _ImageDescription = &quot;&quot;;
        public string ImageDescription
        {
            get { return _ImageDescription; }
            set { _ImageDescription = value; }
        }
        protected override void RenderContents(HtmlTextWriter writer)
        {
            writer.AddAttribute(&quot;onmousemove&quot;, &quot;javascript:document.getElementById('&quot; + this.UniqueID + &quot;_divDescription').style.display='';&quot;);
            writer.AddAttribute(&quot;onmouseout&quot;, &quot;javascript:document.getElementById('&quot; + this.UniqueID + &quot;_divDescription').style.display='none';&quot;);
            writer.AddAttribute(HtmlTextWriterAttribute.Src, _ImageUrl);
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag();
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            writer.Write(&quot;Name : &quot; + _ImageName);
            writer.RenderEndTag();
            writer.AddStyleAttribute(HtmlTextWriterStyle.Display, &quot;none&quot;);
            writer.AddAttribute(HtmlTextWriterAttribute.Id, this.UniqueID + &quot;_divDescription&quot;);
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            writer.Write(&quot;Description : &quot; + _ImageDescription);
            writer.RenderEndTag();
            base.RenderContents(writer);
        }
        protected override HtmlTextWriterTag TagKey
        {
            get
            {
                return HtmlTextWriterTag.Div;
            }
        }
    }
}
</pre>
<p>Registering the control on the web page</p>
<pre class="brush: xml;">

&lt;%@ Register Assembly=&quot;myControlLib&quot; Namespace=&quot;myControlLib&quot; TagPrefix=&quot;myUcl&quot; %&gt;
</pre>
<p>Using the control</p>
<pre class="brush: xml;">

&lt;myUcl:myImage ID=&quot;MyImage1&quot; runat=&quot;server&quot; ImageUrl=&quot;~/images/myImage1.jpg&quot; ImageName=&quot;My Image Name&quot;
ImageDescription=&quot;My Image Description........&quot; /&gt;
</pre>
<p><strong>Note:</strong> The above examples are the simplest controls that one can create. Remember that you can create more complex controls using the same approach. Choosing the best control that can serve the purpose of the requirement is our JOB and so make this decision very carefully.</p>
<p><a title="How to make better appearance of your custom control in Visual Studio." href="http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-make-better-appearance-of-your-custom-control-in-visual-studio/" target="_blank"><span style="color:#ff6600;"><strong>How to make better appearance of your custom control in Visual Studio.</strong></span></a></p>
<p><a title="How to add custom control in Visual Studio Toolbox." href="http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-add-custom-control-in-visual-studio-toolbox/" target="_blank"><span style="color:#ff6600;"><strong>How to add custom control in Visual Studio Toolbox.</strong></span></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dhavalupadhyaya.wordpress.com/60/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dhavalupadhyaya.wordpress.com/60/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dhavalupadhyaya.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dhavalupadhyaya.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dhavalupadhyaya.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dhavalupadhyaya.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dhavalupadhyaya.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dhavalupadhyaya.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dhavalupadhyaya.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dhavalupadhyaya.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dhavalupadhyaya.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dhavalupadhyaya.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=60&subd=dhavalupadhyaya&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dhavalupadhyaya.wordpress.com/2008/07/20/creating-custom-controls-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43e17fb661c7183b78a0ff22ace00644?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">dhavalupadhyaya</media:title>
		</media:content>
	</item>
		<item>
		<title>How to make better appearance of your custom control in Visual Studio.</title>
		<link>http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-make-better-appearance-of-your-custom-control-in-visual-studio/</link>
		<comments>http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-make-better-appearance-of-your-custom-control-in-visual-studio/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 06:55:05 +0000</pubDate>
		<dc:creator>Dhaval Upadhyaya</dc:creator>
				<category><![CDATA[Custom Controls]]></category>
		<category><![CDATA[add web control to toolbox]]></category>
		<category><![CDATA[button in custom control asp.net]]></category>
		<category><![CDATA[Control Class Library]]></category>
		<category><![CDATA[create custum control asp.net]]></category>
		<category><![CDATA[Custom Control in .net]]></category>
		<category><![CDATA[custom control with toolbox image]]></category>
		<category><![CDATA[Custom Controls in .net]]></category>
		<category><![CDATA[Designer for custom control]]></category>
		<category><![CDATA[Desing time attributes]]></category>
		<category><![CDATA[example of custom controls in .net]]></category>
		<category><![CDATA[How to add custom control to toolbox]]></category>
		<category><![CDATA[How to add web control to toolbox]]></category>
		<category><![CDATA[process to create custom controls in asp]]></category>
		<category><![CDATA[Web Controls]]></category>
		<category><![CDATA[WebControls]]></category>
		<category><![CDATA[why create custom controls]]></category>

		<guid isPermaLink="false">http://dhavalupadhyaya.wordpress.com/?p=58</guid>
		<description><![CDATA[How to make better appearance of your custom control in Visual Studio.
In the previous article Creating Custom Controls in ASP .Net I have covered the technical approach for creating custom control.
Here I will explain how to improve the appearance of your custom control
Their are two ways in which this job can be done.
1) By decorating [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=58&subd=dhavalupadhyaya&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>How to make better appearance of your custom control in Visual Studio.</strong></p>
<p>In the previous article <a title="Creating Custom Controls in ASP .Net" href="http://dhavalupadhyaya.wordpress.com/2008/07/20/creating-custom-controls-in-asp-net/" target="_blank"><strong><span style="color:#ff6600;">Creating Custom Controls in ASP .Net</span></strong></a> I have covered the technical approach for creating custom control.</p>
<p>Here I will explain how to improve the appearance of your custom control<br />
Their are two ways in which this job can be done.<br />
1) By decorating your control and control properties with some design time attributes.<br />
2) By making your own control designer.</p>
<p><strong>Decorating your control and control properties with some design time attributes:</strong><br />
.Net provides various design time attributes that can be applied on control or on property to take control over the design aspects of the control. You can do lots of things with this attributes let’s say:</p>
<p>One can choose the default event or default property for their controls.</p>
<p>One can assign the description to the property that is displayed in the last section of the property window when the property is selected.</p>
<p>One can categorize their additional properties in property window. This would be helpful when the property window is switched to &#8220;Categorized&#8221; mode.Etc&#8230;</p>
<p>Their are lots of such attributes with which you can playaround.<br />
Some of them I have described below.<br />
<strong></strong></p>
<p><strong></strong> </p>
<p><strong>Attributes you can apply to your control class:</strong></p>
<p>DefaultEvent &#8211; This attribute specifies the default event for your control. So when a control is double clicked, the event handler is automatically created for this event.</p>
<p>DefaultProperty &#8211; This attribute specifies the default property for your control. So when you open the property window for your control, this property will be focused by default.</p>
<p>ToolboxData &#8211; This attribute allows you to specify any tags that are added to the markup of your control whenever it is added to the page.</p>
<p>ToolboxItem &#8211; This attribute allows you to block the control from appearing in the toolbox.</p>
<p>TagPrefix &#8211; This attribute allows you to manage the html markup for the registration tag of your control.</p>
<p> </p>
<p><strong>Attributes you can apply to your control property:</strong></p>
<p>Bindable &#8211; Displays a data binding dialog box for the property.</p>
<p>Browsable &#8211; This attribute allows you to block the property from appearing in Property window.</p>
<p>Category &#8211; This attribute allows you to group properties in a particular stencil. The property will appear under this category in the property window.</p>
<p>DefaultValue &#8211; This attribute allows you to give default value for the property.</p>
<p>Description &#8211; This attribute allows you to specify the description for the property. This description is displayed below in the property window when the property is selected.</p>
<p>Editor &#8211; This attribute allows you to specify the custom editor window for the property. Examples of custom editor are ImageUrlEditor, MailFileEditor,  MdbDataFileEditor,  UrlEditor etc&#8230;</p>
<p>EditorBrowsable &#8211; This attribute allow you to block a property from being display in the Intellisense.</p>
<p> </p>
<p>Example Source Code</p>
<pre class="brush: csharp;">

private string _ImageUrl = &quot;&quot;;
[Category(&quot;My Custom Properties&quot;)]
[Description(&quot;Specify path of the image to be displayed.&quot;)]
[Editor(&quot;System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot;, typeof(UITypeEditor))]
[DefaultValue(&quot;&quot;)]
[UrlProperty]
[Bindable(true)]
public string ImageUrl
{
    get { return _ImageUrl; }
    set { _ImageUrl = value; }
}
</pre>
<p> </p>
<p><strong>Making your own control designer:</strong><br />
Control Designer help to take control over the appearance of the control when they are drag dropped in the page. One can also create a smart tag that can help user to easily configure some properties of your control. Example: Some of the .Net controls like FormView, DetailsView, GridView have smart tags that help users to easily configure some important properties like Datasource, Templates etc. I will try to cover How to make smart tag controller in my next article.</p>
<p>Example Source Code</p>
<pre class="brush: csharp;">

using System;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;

[assembly: TagPrefix(&quot;myControlLib&quot;, &quot;myUcl&quot;)]
namespace myControlLib
{
public class myImageDesigner : ControlDesigner
{
myImage objmyImage;
public override string GetDesignTimeHtml()
{
if (objmyImage.ImageUrl.Trim().Length == 0)
{
return &quot;
&lt;div style=\&quot;background:yellow;width:100px;\&quot;&gt;&lt;center&gt;Please set Image URL Property!&lt;/center&gt;
&lt;div&gt;&quot;;
}
else
{
return base.GetDesignTimeHtml();
}
}
public override void Initialize(IComponent component)
{
objmyImage = (myImage)component;
base.Initialize(component);
return;
}
}

[Designer(&quot;myControlLib.myImageDesigner,myControlLib&quot;)]
[ToolboxBitmap(typeof(myImage), &quot;myImageLogo.bmp&quot;)]
[ToolboxData(@&quot;&lt;{0}:myImage runat=&quot;&quot;server&quot;&quot; ImageUrl=&quot;&quot; &quot;&quot; ImageName=&quot;&quot; &quot;&quot; ImageDescription=&quot;&quot; &quot;&quot; /&gt;&quot;)]
public class myImage : WebControl
{
public myImage() { }

private string _ImageUrl = &quot;&quot;;
[Category(&quot;My Custom Properties&quot;)]
[Description(&quot;Specify path of the image to be displayed.&quot;)]
[Editor(&quot;System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot;, typeof(UITypeEditor))]
[DefaultValue(&quot;&quot;)]
[UrlProperty]
[Bindable(true)]
public string ImageUrl
{
get { return _ImageUrl; }
set { _ImageUrl = value; }
}

private string _ImageName = &quot;&quot;;
[Category(&quot;My Custom Properties&quot;)]
[Description(&quot;Specify name of the image to be displayed.&quot;)]
public string ImageName
{
get { return _ImageName; }
set { _ImageName = value; }
}

private string _ImageDescription = &quot;&quot;;
[Category(&quot;My Custom Properties&quot;)]
[Description(&quot;Specify description of the image to be displayed.&quot;)]
public string ImageDescription
{
get { return _ImageDescription; }
set { _ImageDescription = value; }
}

protected override void RenderContents(HtmlTextWriter writer)
{
writer.AddAttribute(&quot;onmousemove&quot;, &quot;javascript:document.getElementById('&quot; + this.UniqueID + &quot;_divDescription').style.display='';&quot;);
writer.AddAttribute(&quot;onmouseout&quot;, &quot;javascript:document.getElementById('&quot; + this.UniqueID + &quot;_divDescription').style.display='none';&quot;);
writer.AddAttribute(HtmlTextWriterAttribute.Src, _ImageUrl);
writer.RenderBeginTag(HtmlTextWriterTag.Img);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.Write(&quot;Name : &quot; + _ImageName);
writer.RenderEndTag();
writer.AddStyleAttribute(HtmlTextWriterStyle.Display, &quot;none&quot;);
writer.AddAttribute(HtmlTextWriterAttribute.Id, this.UniqueID + &quot;_divDescription&quot;);
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.Write(&quot;Description : &quot; + _ImageDescription);
writer.RenderEndTag();
base.RenderContents(writer);
}

protected override HtmlTextWriterTag TagKey
{
get
{
return HtmlTextWriterTag.Div;
}
}
}
}
</pre>
<p><strong>Note:</strong> Do not forget to add a .bmp image named (&#8220;myImageLogo.bmp&#8221;) to this project. This image would be displayed as the icon for your control in the toolbox. You can also create .bmp file using inbuilt .Net design tool. Just click on the added .bmp file to open this editor.<br />
Your bmp should be 16&#215;16 pixels in size.</p>
<p> </p>
<p>To add custom control to your toolbox refere<br />
<a title="How to add custom control in Visual Studio Toolbox." href="http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-add-custom-control-in-visual-studio-toolbox/" target="_blank"><span style="color:#ff6600;"><strong>How to add custom control in Visual Studio Toolbox.</strong></span></a></p>
<p><strong><span style="color:#ff6600;">  </span></strong></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dhavalupadhyaya.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dhavalupadhyaya.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dhavalupadhyaya.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dhavalupadhyaya.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dhavalupadhyaya.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dhavalupadhyaya.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dhavalupadhyaya.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dhavalupadhyaya.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dhavalupadhyaya.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dhavalupadhyaya.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dhavalupadhyaya.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dhavalupadhyaya.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=58&subd=dhavalupadhyaya&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-make-better-appearance-of-your-custom-control-in-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43e17fb661c7183b78a0ff22ace00644?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">dhavalupadhyaya</media:title>
		</media:content>
	</item>
		<item>
		<title>How to add custom control in Visual Studio Toolbox.</title>
		<link>http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-add-custom-control-in-visual-studio-toolbox/</link>
		<comments>http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-add-custom-control-in-visual-studio-toolbox/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 06:54:37 +0000</pubDate>
		<dc:creator>Dhaval Upadhyaya</dc:creator>
				<category><![CDATA[Custom Controls]]></category>
		<category><![CDATA[add web control to toolbox]]></category>
		<category><![CDATA[button in custom control asp.net]]></category>
		<category><![CDATA[Control Class Library]]></category>
		<category><![CDATA[create custum control asp.net]]></category>
		<category><![CDATA[Custom Control in .net]]></category>
		<category><![CDATA[custom control with toolbox image]]></category>
		<category><![CDATA[Custom Controls in .net]]></category>
		<category><![CDATA[Designer for custom control]]></category>
		<category><![CDATA[Desing time attributes]]></category>
		<category><![CDATA[example of custom controls in .net]]></category>
		<category><![CDATA[How to add custom control to toolbox]]></category>
		<category><![CDATA[How to add web control to toolbox]]></category>
		<category><![CDATA[process to create custom controls in asp]]></category>
		<category><![CDATA[Web Controls]]></category>
		<category><![CDATA[WebControls]]></category>
		<category><![CDATA[why create custom controls]]></category>

		<guid isPermaLink="false">http://dhavalupadhyaya.wordpress.com/?p=49</guid>
		<description><![CDATA[How to add custom control in Visual Studio Toolbox.
In my previous article Creating Custom Controls in ASP .Net  we have seen the technical approach for creating custom control and  in How to make better appearance of your custom control in Visual Studio we have gone through the design aspects of custom control.
Now in this article [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=49&subd=dhavalupadhyaya&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong><a href="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_1.jpg"></a>How to add custom control in Visual Studio Toolbox.</strong></p>
<p>In my previous article <a title="Creating Custom Controls in ASP .Net" href="http://dhavalupadhyaya.wordpress.com/category/microsoft-net-20/custom-controls/" target="_blank"><strong><span style="color:#ff6600;">Creating Custom Controls in ASP .Net</span></strong> </a> we have seen the technical approach for creating custom control and  in <a title="How to make better appearance of your custom control in Visual Studio." href="http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-make-better-appearance-of-your-custom-control-in-visual-studio/" target="_blank"><strong><span style="color:#ff6600;">How to make better appearance of your custom control in Visual Studio</span></strong></a> we have gone through the design aspects of custom control.</p>
<p>Now in this article I will explain how to add your custom control to your Toolbox.</p>
<p> </p>
<p><span style="text-decoration:underline;">Making Custom Control Class Library Project.</span></p>
<p><strong>Step 1</strong> &#8211; Create a class library project named myControlLib.</p>
<p><strong>Step 2</strong> &#8211; Add the following code to a new class named myImage. To download sample code files <a title="Custom Control Class Library by Dhaval Upadhyaya" href="http://upadhyayadhaval.googlepages.com/myControlLib.zip" target="_blank"><span style="color:#ff6600;">click here</span></a>. After downloading add “myImage.cs” and “myImageLogo.bmp” file to your “myControlLib” project. Change the “Build Action” property of “myImageLogo.bmp” to Embedded Resource.</p>
<p><strong>Step 3</strong> &#8211; Compile the project.</p>
<p><strong>Note</strong>: Above given steps are specific to the code sample that I have created. If you want to rename any of the file or change any other aspects than make sure that you also change the design time attributes of your control.</p>
<p>Example: [Designer ("myControlLib.myImageDesigner,myControlLib")] uses the namespace “myControlLib” that is directly related to the name of the class library project you make.</p>
<p> </p>
<p><span style="text-decoration:underline;">Adding custom control to toolbox.</span></p>
<p><strong>Step 1</strong> &#8211; Switch over to the web project in which you want to use the control.</p>
<p><strong>Step 2</strong> &#8211; In toolbox add your own tab or click on general tab.</p>
<p><strong>Step 3</strong> &#8211; Right click in the selected tab area and click Chose Items.</p>
<p><img class="alignnone size-full wp-image-44" src="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_1.jpg?w=510&#038;h=294" alt="" width="510" height="294" /></p>
<p><strong>Step 4</strong> &#8211; This will open Choose Toolbox Item screen. Click on Browse button and specify the path of dll you created in your myControlLib project.</p>
<p><img class="alignnone size-full wp-image-44" src="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_2.jpg?w=510&#038;h=294" alt="" width="510" height="294" /></p>
<p><img class="alignnone size-full wp-image-44" src="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_3.jpg?w=510&#038;h=294" alt="" width="510" height="294" /></p>
<p><strong>Step 5</strong> &#8211; Click Ok and you’re done. Your Custom control will be added to the toolbox as shown below.</p>
<p><img class="alignnone size-full wp-image-44" src="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_4.jpg?w=510&#038;h=294" alt="" width="510" height="294" /></p>
<p><img class="alignnone size-full wp-image-44" src="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_5.jpg?w=510&#038;h=294" alt="" width="510" height="294" /></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dhavalupadhyaya.wordpress.com/49/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dhavalupadhyaya.wordpress.com/49/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dhavalupadhyaya.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dhavalupadhyaya.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dhavalupadhyaya.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dhavalupadhyaya.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dhavalupadhyaya.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dhavalupadhyaya.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dhavalupadhyaya.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dhavalupadhyaya.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dhavalupadhyaya.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dhavalupadhyaya.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=49&subd=dhavalupadhyaya&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dhavalupadhyaya.wordpress.com/2008/07/20/how-to-add-custom-control-in-visual-studio-toolbox/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43e17fb661c7183b78a0ff22ace00644?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">dhavalupadhyaya</media:title>
		</media:content>

		<media:content url="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_1.jpg" medium="image" />

		<media:content url="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_2.jpg" medium="image" />

		<media:content url="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_3.jpg" medium="image" />

		<media:content url="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_4.jpg" medium="image" />

		<media:content url="http://dhavalupadhyaya.files.wordpress.com/2008/07/step_2_5.jpg" medium="image" />
	</item>
		<item>
		<title>Application Caching in .Net 2.0</title>
		<link>http://dhavalupadhyaya.wordpress.com/2008/07/05/application-caching-in-net-20/</link>
		<comments>http://dhavalupadhyaya.wordpress.com/2008/07/05/application-caching-in-net-20/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 11:38:19 +0000</pubDate>
		<dc:creator>Dhaval Upadhyaya</dc:creator>
				<category><![CDATA[Caching]]></category>
		<category><![CDATA[Application Caching]]></category>
		<category><![CDATA[Application Caching in .Net 2.0]]></category>
		<category><![CDATA[caching .net]]></category>
		<category><![CDATA[caching application block sample]]></category>
		<category><![CDATA[caching block sample]]></category>
		<category><![CDATA[Caching in .net 2.0]]></category>
		<category><![CDATA[Caching in dot net]]></category>
		<category><![CDATA[Caching in dotnet]]></category>
		<category><![CDATA[difference between cache and application]]></category>
		<category><![CDATA[difference between cache.add and cache.insert]]></category>
		<category><![CDATA[How to cache data]]></category>
		<category><![CDATA[How to cache data in .net]]></category>
		<category><![CDATA[How to cache objects]]></category>
		<category><![CDATA[in technology]]></category>
		<category><![CDATA[what is cache in.net]]></category>

		<guid isPermaLink="false">http://dhavalupadhyaya.wordpress.com/?p=38</guid>
		<description><![CDATA[Application Caching in .Net 2.0
What is Application Caching?
Application Caching is a technique in .Net 2.0 for caching different type of objects for faster access. As the name itself depicts, the Cache Object can be used from the entire application. A single cache object lies for the entire application and so can be used between various [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=38&subd=dhavalupadhyaya&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Application Caching in .Net 2.0</strong></p>
<p><strong>What is Application Caching?</strong><br />
Application Caching is a technique in .Net 2.0 for caching different type of objects for faster access. As the name itself depicts, the Cache Object can be used from the entire application. A single cache object lies for the entire application and so can be used between various different user sessions and requests.</p>
<p><strong><span style="color:#000000;">How Application Caching works and How to use it?</span></strong><br />
The main motive for Application Caching is to store cached Objects in memory for faster access. Expensive operation to obtain and persists data or information can lead to application failure or sluggishness at time of heavy traffic. Also the amount of time and resources involved in such operations may not be satisfactionary. So to improve upon the performance and the scalability of your application you can cache the expensive data for faster access.</p>
<p>You can use either Cache.Add() or Cache.Insert() methods for caching your data. The only difference between the two is, Cache.Add() method returns the object which you want to cache.<br />
So let’s say if you want to use the object and cache it as well. You can do so in a single line of code with the help of Cache.Add().</p>
<p>Cache.Insert() methods has 4 different types of overloaded methods while Cache.Add() has only one.</p>
<p><strong></strong></p>
<p><strong>Different Parameters used for the above methods:</strong></p>
<p><strong><span style="color:#000000;">Key</span></strong><br />
It is the name for the cached object by which it will be accessed. You can also use the key to remove the cached object from the memory. Following code will remove the cached object named “customerList” from the memory.</p>
<pre class="brush: csharp;">
Cache.Remove(&quot;customerList&quot;);
</pre>
<p><strong>Object to be cached</strong><br />
It is the object that you want to cache. This object will be stored in the memory for faster retrieval.</p>
<p> <br />
<strong>Dependency</strong><br />
It is the CacheDependency object that can be a file or cache key. So if the file or cache key is changed than the object in the cached will be invalidated and removed from the cache. This can be used to maintain the freshness of the data. This is an optional parameter. You can set it to null. Incase of multiple dependency conditions you can use AggregateCacheDependency object instead of CacheDependency.</p>
<p> <br />
<strong>Absolute Expiration Date<br />
</strong>It is the time at which the object will be removed from the cache. To remove the object from cache after 10 minutes you can set this parameter to DateTime.Now.AddMinutes(10) as shown in the below code.</p>
<pre class="brush: csharp;">
Cache.Insert(&quot;customerList&quot;, objDataSet,
new CacheDependency(Server.MapPath(&quot;~/App_Data/customerList.xml&quot;)),
DateTime.Now.AddMinutes(10), Cache.NoSlidingExpiration,
CacheItemPriority.Normal, null);
</pre>
<p>If you do not want the object to expire forcefully after some time than you may set this parameter to Cache.NoAbsoluteExpiration as shown in below code.</p>
<pre class="brush: csharp;">
Cache.Insert(&quot;customerList&quot;, objDataSet,
new CacheDependency(Server.MapPath(&quot;~/App_Data/customerList.xml&quot;)),
Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
CacheItemPriority.Normal, null);
</pre>
<p><strong>Time Span</strong><br />
It is the time span after which the object will be removed from the cache if it was not accessed. So lets say if you want to remove the object from cache if it has not been accessed since last 10 minutes than you can use the below code.</p>
<pre class="brush: csharp;">
Cache.Insert(&quot;customerList&quot;, objDataSet,
new CacheDependency(Server.MapPath(&quot;~/App_Data/customerList.xml&quot;)),
Cache.NoAbsoluteExpiration,DateTime.Now.AddMinutes(10),
CacheItemPriority.Normal, null);
</pre>
<p>If you do not want the object to expire forcefully after some time it was last accessed than you may set this parameter to use Cache.NoSlidingExpiration  as shown in below code.</p>
<pre class="brush: csharp;">
Cache.Insert(&quot;customerList&quot;, objDataSet,
new CacheDependency(Server.MapPath(&quot;~/App_Data/customerList.xml&quot;)),
Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
CacheItemPriority.Normal, null);
</pre>
<p>Note: If you are using this sliding expiration time parameter than Absolute Expiration Date parameter must be Cache.NoAbsoluteExpiration<br />
<strong></strong></p>
<p><strong></strong> </p>
<p><strong>Priority</strong><br />
It is the priority at which the objects will be purged from the memory incase if the memory runs low. Lower priority objects will be removed first.<br />
<strong></strong></p>
<p><strong></strong> </p>
<p><strong>Callback Method</strong><br />
It is the event handler that will run when the object is removed from the cache. If you do not want to use this parameter than you can set this to null.</p>
<p> <br />
<span><span style="color:#ff6600;">To download Application caching code sample </span><a title="Application Caching code sample by Dhaval Upadhyaya" href="http://upadhyayadhaval.googlepages.com/ApplicationCaching.zip" target="_blank"><span style="color:#ff6600;">Click Here</span></a><span style="color:#ff6600;">.</span></span></p>
<p> <br />
<strong>Note</strong>: To introduce sophisticated caching layer in your application you can always use Microsoft’s Enterprise Library &#8211; Caching Application Block.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dhavalupadhyaya.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dhavalupadhyaya.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dhavalupadhyaya.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dhavalupadhyaya.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dhavalupadhyaya.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dhavalupadhyaya.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dhavalupadhyaya.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dhavalupadhyaya.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dhavalupadhyaya.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dhavalupadhyaya.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dhavalupadhyaya.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dhavalupadhyaya.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=38&subd=dhavalupadhyaya&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dhavalupadhyaya.wordpress.com/2008/07/05/application-caching-in-net-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43e17fb661c7183b78a0ff22ace00644?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">dhavalupadhyaya</media:title>
		</media:content>
	</item>
		<item>
		<title>Understanding Globalization and Localization in .NET</title>
		<link>http://dhavalupadhyaya.wordpress.com/2008/06/21/globalizing-a-webpage-innet/</link>
		<comments>http://dhavalupadhyaya.wordpress.com/2008/06/21/globalizing-a-webpage-innet/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 04:36:43 +0000</pubDate>
		<dc:creator>Dhaval Upadhyaya</dc:creator>
				<category><![CDATA[Globalization]]></category>
		<category><![CDATA[Globalization in .Net]]></category>
		<category><![CDATA[Globalization in web page]]></category>
		<category><![CDATA[Globalization in web application]]></category>
		<category><![CDATA[Globalization in webapplication]]></category>
		<category><![CDATA[resource files in .net]]></category>
		<category><![CDATA[.resx file in .net]]></category>
		<category><![CDATA[implicit localization]]></category>
		<category><![CDATA[implicit globalization]]></category>
		<category><![CDATA[Programmatic localization]]></category>
		<category><![CDATA[Programmatic globalization]]></category>
		<category><![CDATA[local resource files]]></category>
		<category><![CDATA[global resource files]]></category>
		<category><![CDATA[localization in .net]]></category>
		<category><![CDATA[setting UICulture]]></category>
		<category><![CDATA[Understanding Globalization in.Net]]></category>
		<category><![CDATA[Understanding Globalization and Localization in .NET]]></category>
		<category><![CDATA[global resources and local resources]]></category>
		<category><![CDATA[select a different cultur for a webpage]]></category>
		<category><![CDATA[implicit global resource]]></category>
		<category><![CDATA[.net "generate local resource" culture]]></category>
		<category><![CDATA[getglobalresourceobject in different lan]]></category>
		<category><![CDATA[example of localization in .net]]></category>
		<category><![CDATA[set the globalization and localization]]></category>
		<category><![CDATA[.net globalresource aspx]]></category>
		<category><![CDATA[globalization + .net]]></category>
		<category><![CDATA[global resx file culture]]></category>
		<category><![CDATA[asp globalization resource in title]]></category>
		<category><![CDATA[globalization of .net web application]]></category>
		<category><![CDATA[getlocalresourceobject subfolder]]></category>
		<category><![CDATA[change global $resource localization]]></category>
		<category><![CDATA[how to use globalization for entire page]]></category>
		<category><![CDATA[app_GlobalResources vs app_LocalResources]]></category>
		<category><![CDATA[asp.net creating global resource file]]></category>
		<category><![CDATA[globalization & localization in .net(2.0)]]></category>

		<guid isPermaLink="false">http://dhavalupadhyaya.wordpress.com/?p=33</guid>
		<description><![CDATA[Understanding Globalization and Localization in .NET
Now days as the audience for web applications has bursted from computers to pda&#8217;s, cell phones and many other gadgets, Globalization has become must for web application. Globalization allows your web application to be useful for different people in different parts of the world who speaks different languages.
Thanks to Microsoft [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=33&subd=dhavalupadhyaya&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Understanding Globalization and Localization in .NET</strong></p>
<p>Now days as the audience for web applications has bursted from computers to pda&#8217;s, cell phones and many other gadgets, Globalization has become must for web application. Globalization allows your web application to be useful for different people in different parts of the world who speaks different languages.</p>
<p>Thanks to Microsoft .Net Globalization feature.</p>
<p>Using this feature one can easily build a web application available to dispersed audience throughout the world.</p>
<p>In this article I will walkthrough the steps that are essential for creating a multi cultured application. This example will include the use of Global and Local resource files that are heart for multi cultured web application.</p>
<p>ASP.Net supports two types of resources</p>
<p>Local Resource and Global Resource.</p>
<p>Both types of Resources are xml based resource files that can contain text translated into particular language</p>
<p><strong>Local Resources:</strong></p>
<p>Local resource is specific to particular webpage. All the resource files related to particular webpage must be placed in a special .Net folder named App_LocalResources. This folder must be in the same folder of the webpage that you want to localize. So App_LocalResources can be subfolder for any folder of your website.</p>
<p><strong>Global Resources:</strong></p>
<p>They are the resource files for the entire web application. They are not specific to any page. They can be accessed from the entire web application. Global resource files must be located in a special .Net folder named App_GlobalResources. App_GlobalResources must be at the root of the web application.</p>
<p><strong>Steps to create local Resource file.</strong></p>
<p>1) Switch to design view of the webpage for which you want to create the resource file.</p>
<p>2) Go to Tools menu and click Generate Local Resource.</p>
<p>3) As the result of step 2 .Net generates the .resx file.</p>
<p>Naming conventions that Resource files follow is as explained below:</p>
<p>&lt;PageName&gt;.aspx.&lt;language&gt;.resx</p>
<p>Example</p>
<p>myWebPage.aspx.resx: This is the default resource file of your page. If no culture matches than this resource file is used.</p>
<p>myWebPage.aspx.es.resx: For Neutral Spanish culture it may look like this.</p>
<p>myWebPage.aspx.es-MX.resx: For Specific Spanish Mexican culture it may look like this.</p>
<p>What do you mean by neutral and specific cultures? I leave this small exercise to readers.</p>
<p><strong>Steps to create global Resource file.</strong></p>
<p>1) Their are no specific utilities in .Net to generate Global resource files automatically. But you can create App_GlobalResources folder at root level and add a resource file manually Or you may copy the local resource file and change it at your will.</p>
<p><strong>Ways in which you can Globalize or localize your application.</strong></p>
<p> <br />
Implicit Localization</p>
<pre class="brush: xml;">

&lt;asp:Label ID=&quot;lblLoadLocalResource&quot; runat=&quot;server&quot; 

Text=&quot;Local Resource&quot; 

meta:resourcekey=&quot;lblLoadLocalResourceResource1&quot;&gt;

&lt;/asp:Label&gt;
</pre>
<p> </p>
<p>Implicit Globalization</p>
<pre class="brush: xml;">

&lt;asp:Label ID=&quot;lblLoadGlobalResource&quot; runat=&quot;server&quot; 

Text=&quot;&lt;%$ Resources:Resource, commonHeader %&gt;&quot; 

ToolTip=&quot;&lt;%$ Resources:Resource, commonHeader %&gt;&quot;&gt;

&lt;/asp:Label&gt;
</pre>
<p> </p>
<p>Programmatic Localization</p>
<pre class="brush: csharp;">

lblLoadLocalResource.Text = GetLocalResourceObject
(&quot;lblLoadLocalResourceResource1.Text&quot;).ToString();

lblLoadLocalResource.ToolTip = GetLocalResourceObject
(&quot;lblLoadLocalResourceResource1.ToolTip&quot;).ToString();
</pre>
<p> </p>
<p>Programmatic Globalization</p>
<pre class="brush: csharp;">

lblLoadGlobalResource.Text = GetGlobalResourceObject
(&quot;Resource&quot;, &quot;commonHeader&quot;).ToString();

lblLoadGlobalResource.ToolTip = GetGlobalResourceObject
(&quot;Resource&quot;, &quot;commonHeader&quot;).ToString();
</pre>
<p> </p>
<p> </p>
<p><strong>H</strong><strong>ow to change the UI Culture?</strong></p>
<p>Steps to check and configure the UI Culture of your webpage</p>
<p>1) To change it programmatically you need to override the InitializeCulture() of your web page.</p>
<pre class="brush: csharp;">
protected override void InitializeCulture()
{
 UICulture = &quot;en&quot;;
}
</pre>
<p> </p>
<p>2) To change it implicitly from .aspx page Set</p>
<pre class="brush: xml;">
&lt;%@ Page Language=&quot;C#&quot; UICulture=&quot;en&quot; %&gt;
</pre>
<p>3)To change it globally from web.config file</p>
<pre class="brush: xml;">
&lt;system.web&gt;
 &lt;globalization uiCulture=&quot;es&quot;/&gt;
&lt;/system.web&gt;
</pre>
<p><strong>Note</strong>: If you set UICulture=&#8221;auto&#8221; then .Net runtime will automatically detect the requesting browsers preferred language setting and will compile the related resource file for that culture. In this case you do not have to write a single piece of code for setting UICulture.</p>
<p><strong>How to check this?</strong></p>
<p>1) Open IE and go to Tools &gt; internet Options</p>
<p>2) Click Languages tab.</p>
<p>3) This will open language Preference dialog box window.</p>
<p>4) Add the language by clicking the add button. Make sure to add the language for which you have configured the resource file of your web page.</p>
<p>5) Select the language that you have added and using Move Up button, bring it to the first topmost position in the language list.</p>
<p>6) Press Ok and again Ok to return.</p>
<p>Open your webpage in the browser and enjoy the taste of globalized web application.</p>
<p>I believe that few lines of code can speak thousand words and so I have prepared a small demo that includes both Globalization and Localization.</p>
<p><span><span style="color:#f92305;">To download the entire source code </span><a title="Globalization in .Net Code Sample by Dhaval Upadhyaya" href="http://upadhyayadhaval.googlepages.com/Globalization.zip" target="_blank"><span style="color:#f92305;">Click Here</span></a><span style="color:#f92305;">.</span></span></p>
<p><strong>Note</strong>: Globalizing the web application entirely, requires lots of other things like changing the Culture, formatting dates and currency and lot more. I will try to incorporate all this stuff in my next article.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dhavalupadhyaya.wordpress.com/33/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dhavalupadhyaya.wordpress.com/33/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dhavalupadhyaya.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dhavalupadhyaya.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dhavalupadhyaya.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dhavalupadhyaya.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dhavalupadhyaya.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dhavalupadhyaya.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dhavalupadhyaya.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dhavalupadhyaya.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dhavalupadhyaya.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dhavalupadhyaya.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dhavalupadhyaya.wordpress.com&blog=3874716&post=33&subd=dhavalupadhyaya&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dhavalupadhyaya.wordpress.com/2008/06/21/globalizing-a-webpage-innet/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/43e17fb661c7183b78a0ff22ace00644?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">dhavalupadhyaya</media:title>
		</media:content>
	</item>
	</channel>
</rss>