<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-8980734269859237005</atom:id><lastBuildDate>Tue, 10 Nov 2009 07:56:53 +0000</lastBuildDate><title>DevCurry</title><description /><link>http://www.devcurry.com/</link><managingEditor>noreply@blogger.com (Suprotim Agarwal)</managingEditor><generator>Blogger</generator><openSearch:totalResults>317</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/devcurry" type="application/rss+xml" /><feedburner:emailServiceId>devcurry</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-1104002528160711531</guid><pubDate>Mon, 09 Nov 2009 16:22:00 +0000</pubDate><atom:updated>2009-11-09T08:24:28.198-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><title>Prevent an ASP.NET Application Restart when a Configuration Setting is changed</title><description>&lt;p align="justify"&gt;A change to configuration settings in your web.config leads to an application restart, affecting the Session and Cache objects. How do you prevent it? The answer is by placing configuration information in an external file. To do so, use the little known attribute called ‘&lt;a href="http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.configsource.aspx"&gt;configSource&lt;/a&gt;’ as shown below:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;connectionStrings &lt;/span&gt;&lt;span style="color:red;"&gt;configSource&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"M&lt;span style="color:blue;"&gt;yconn.config&lt;/span&gt;"&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;In the Myconn.config file, declare the connectionStrings as follows:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;connectionStrings&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;add &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;nwstring&lt;/span&gt;" &lt;span style="color:red;"&gt;connectionString&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;Data Source=(local);Initial&lt;br /&gt;Catalog=Northwind;Integrated Security=true;&lt;/span&gt;"&lt;br /&gt;&lt;span style="color:red;"&gt;providerName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;System.Data.SqlClient&lt;/span&gt;" &lt;span style="color:blue;"&gt;/&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;connectionStrings&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;Now you can go ahead and change the connectionString even in a live application without worrying about an application restart!&lt;/p&gt;&lt;p&gt;Make sure you also read about the &lt;a href="http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.restartonexternalchanges.aspx"&gt;RestartOnExternalChanges&lt;/a&gt; property.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-1104002528160711531?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/WDtWgcDu75k" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/WDtWgcDu75k/prevent-aspnet-application-restart-when.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/11/prevent-aspnet-application-restart-when.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-2085747663970382476</guid><pubDate>Mon, 09 Nov 2009 00:20:00 +0000</pubDate><atom:updated>2009-11-08T23:22:34.247-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><title>Disabling Debug Mode and Tracing in your ASP.NET applications</title><description>&lt;p&gt;To improve the performance of our ASP.NET application, a recommended practice is to make sure that the application is not deployed with Debug=True attribute.&lt;/p&gt;&lt;p&gt;One of my clients had a production server which hosted multiple websites. Although some of the applications were deployed keeping debug=false, however the rest of the applications had the attribute set to true. They now wanted to control the setting from the machine.config file which would apply to all the applications running on that server.&lt;/p&gt;&lt;p&gt;Here’s a technique that most of the users to not know about. In your machine.config, locate the &amp;lt;system.web&amp;gt; section and add the following entry&lt;/p&gt;&lt;p&gt;&amp;lt;deployment retail=“true”/&amp;gt;&lt;/p&gt;&lt;p&gt;That’s it. Now this setting will automatically disable the debug mode and tracing on your applications.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-2085747663970382476?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/zF3JyjwFyeA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/zF3JyjwFyeA/disabling-debug-mode-and-tracing-in.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/11/disabling-debug-mode-and-tracing-in.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-4913110823810387243</guid><pubDate>Sun, 08 Nov 2009 01:40:00 +0000</pubDate><atom:updated>2009-11-07T21:41:27.202-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Tools</category><title>8 Useful FireFox Addons For Web Designers</title><description>&lt;p&gt;Here are some FireFox Add-ons I have found extremely useful while designing web applications. The description of each add-on has been taken from the the official page.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/271" target="_blank"&gt;ColorZilla&lt;/a&gt;&lt;/strong&gt; - With ColorZilla you can get a color reading from any point in your browser, quickly adjust this color and paste it into another program. You can Zoom the page you are viewing and measure distances between any two points on the page. The built-in palette browser allows choosing colors from pre-defined color sets and saving the most used colors in custom palettes. DOM spying features allow getting various information about DOM elements quickly and easily. A very useful FireFox extension indeed!&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/8487" target="_blank"&gt;Pencil&lt;/a&gt;&lt;/strong&gt; – A very handy add-on to create diagrams and GUI prototyping&lt;/p&gt;&lt;p&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/13383" target="_blank"&gt;&lt;strong&gt;ColorSuckr&lt;/strong&gt;&lt;/a&gt;  – Extracts colors from images and builds color schemes&lt;/p&gt;&lt;p&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/2498" target="_blank"&gt;&lt;strong&gt;Yet Another Window Resizer&lt;/strong&gt;&lt;/a&gt; - Resize browser window to default screen resolutions&lt;/p&gt;&lt;p&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/5648" target="_blank"&gt;&lt;strong&gt;FireShot&lt;/strong&gt;&lt;/a&gt; - A Firefox extension that creates screenshots of web pages (entirely or just visible part).  You can also insert text annotations and graphical annotations to the screenshot.&lt;/p&gt;&lt;p&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/539" target="_blank"&gt;&lt;strong&gt;MeasureIt&lt;/strong&gt;&lt;/a&gt; - Draw out a ruler to get the pixel width and height of any elements on a webpage&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/60"&gt;Web Developer&lt;/a&gt;&lt;/strong&gt; - Adds a menu and a toolbar with various web developer tools&lt;/p&gt;&lt;p&gt;and the last one which is a must have for every web developer/designer&lt;/p&gt;&lt;p&gt;&lt;a href="http://getfirebug.com/"&gt;&lt;strong&gt;FireBug&lt;/strong&gt;&lt;/a&gt; - Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-4913110823810387243?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/gmTYg-ZSHdc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/gmTYg-ZSHdc/8-useful-firefox-addons-for-web.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/11/8-useful-firefox-addons-for-web.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-3747796243406935487</guid><pubDate>Fri, 06 Nov 2009 12:55:00 +0000</pubDate><atom:updated>2009-11-06T04:55:00.432-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Using IsDebuggingEnabled in ASP.NET</title><description>&lt;p align="justify"&gt;A cool feature in the .NET library that I rarely see used is the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.httpcontext.isdebuggingenabled.aspx"&gt;IsDebuggingEnabled&lt;/a&gt; property. This returns a value indicating whether the current HTTP request is in debug mode. I’ve found this useful in the past where I wanted something displayed on the screen to distinguish if the website I’m working on is a debug build or not. To change the compilation of a website, you update the compilation element in the web.config file:&lt;/p&gt;&lt;p&gt;Debugging is off: &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;compilation &lt;/span&gt;&lt;span style="color:red;"&gt;debug&lt;/span&gt;&lt;span style="color:blue;"&gt;="false"&amp;gt;&lt;br /&gt;&lt;/span&gt;Debugging is on: &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;compilation&lt;/span&gt;&lt;span style="color:red;"&gt;debug&lt;/span&gt;&lt;span style="color:blue;"&gt;="true"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p align="justify"&gt;The following code demonstrates how to use this property. When page is loaded and debugging is enabled, a JavaScript alert will be displayed:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;html &lt;/span&gt;&lt;span style="color:red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://www.w3.org/1999/xhtml" &amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;head &lt;/span&gt;&lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;="Head2" &lt;/span&gt;&lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;title&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;title&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script &lt;/span&gt;&lt;span style="color:red;"&gt;language&lt;/span&gt;&lt;span style="color:blue;"&gt;="javascript" &lt;/span&gt;&lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;="text/javascript"&lt;br /&gt;    &lt;/span&gt;&lt;span style="color:red;"&gt;src&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://code.jquery.com/jquery-latest.js"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script &lt;/span&gt;&lt;span style="color:red;"&gt;language&lt;/span&gt;&lt;span style="color:blue;"&gt;="javascript" &lt;/span&gt;&lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;="text/javascript"&amp;gt;&lt;br /&gt;&lt;/span&gt;$(document).ready(&lt;span style="color:blue;"&gt;function&lt;/span&gt;() {&lt;br /&gt;&lt;span style="color:blue;"&gt;if &lt;/span&gt;(&lt;span style="color:#a31515;"&gt;'&amp;lt;%= System.Web.HttpContext.Current.IsDebuggingEnabled %&amp;gt;' &lt;/span&gt;== &lt;span style="color:#a31515;"&gt;'True'&lt;/span&gt;) {&lt;br /&gt;            alert(&lt;span style="color:#a31515;"&gt;"Debugging enabled!"&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;});&lt;br /&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;head&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;body&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;form &lt;/span&gt;&lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;="form1" &lt;/span&gt;&lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;       &lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;form&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;body&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;html&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;I find this piece of code very useful if I want to see results that I would not want to be displayed, in a production environment.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-3747796243406935487?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/0SUkII2jeBc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/0SUkII2jeBc/using-isdebuggingenabled-in-aspnet.html</link><author>noreply@blogger.com (Malcolm Sheridan)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/11/using-isdebuggingenabled-in-aspnet.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-9052743068308834106</guid><pubDate>Thu, 05 Nov 2009 12:55:00 +0000</pubDate><atom:updated>2009-11-05T04:55:00.619-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VB.NET</category><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Find the Last Day of the Previous Month using C# and VB.NET</title><description>&lt;p&gt;A couple of days ago, I had written a post to &lt;a href="http://www.devcurry.com/2009/05/find-first-and-last-day-of-current.html"&gt;Find the First and Last Day of the Current Quarter&lt;/a&gt; using C#/VB.NET. A user commented asking how to find the last day of the previous month. Here’s how it can be done:&lt;/p&gt;&lt;p&gt;C#&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:#2b91af;"&gt;DateTime &lt;/span&gt;dt = &lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt;.Now;&lt;br /&gt;&lt;span style="color:#2b91af;"&gt;DateTime &lt;/span&gt;lstDay = &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;DateTime&lt;/span&gt;(dt.Year, dt.Month, 1);&lt;br /&gt;lstDay = lstDay.AddDays(-1);&lt;br /&gt;&lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;"Month: {0}, LastDate: {1}"&lt;/span&gt;,lstDay.Month, lstDay.Day);&lt;br /&gt;&lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.Read();&lt;/pre&gt;&lt;p&gt;VB.NET&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;Dim &lt;/span&gt;dt &lt;span style="color:blue;"&gt;As &lt;/span&gt;DateTime = DateTime.Now&lt;br /&gt;&lt;span style="color:blue;"&gt;Dim &lt;/span&gt;lstDay &lt;span style="color:blue;"&gt;As New &lt;/span&gt;DateTime(dt.Year, dt.Month, 1)&lt;br /&gt;lstDay = lstDay.AddDays(-1)&lt;br /&gt;Console.WriteLine("Month: {0}, LastDate: {1}",lstDay.Month, lstDay.Day)&lt;br /&gt;Console.Read()&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_0j4bzarlOBg/SvFKNR4QiJI/AAAAAAAAAd8/pFaxp7WChVM/s1600-h/image%5B2%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="38" alt="image" src="http://lh4.ggpht.com/_0j4bzarlOBg/SvFKOpX87wI/AAAAAAAAAeA/CR3Snm0WugE/image_thumb.png?imgmax=800" width="204" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;The current month is November, so the last day of the previous month (October) is 31.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-9052743068308834106?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/ZliLcrGe-90" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/ZliLcrGe-90/find-last-day-of-previous-month-using-c.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/11/find-last-day-of-previous-month-using-c.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-1903812791005428684</guid><pubDate>Wed, 04 Nov 2009 12:55:00 +0000</pubDate><atom:updated>2009-11-04T04:55:00.096-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VB.NET</category><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Check if a Float number falls within a range using Extension Methods</title><description>&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx" target="_blank"&gt;Extension methods&lt;/a&gt; enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. I was having a conversation with a bunch of C# 2.0 developers the other day who were planning to move to C# 3.0 and then 4.0.  They had a requirement to check if a number falls within a specific range and wanted to see how this could be done in 3.0. I said use Extension Methods. Here’s some code that checks if a float number falls within a range, using an Extension Method&lt;/p&gt;&lt;p&gt;C#&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;static class &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;Program&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color:blue;"&gt;public static void &lt;/span&gt;Main(&lt;span style="color:blue;"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:blue;"&gt;float &lt;/span&gt;number = 23.5f;&lt;br /&gt;        &lt;span style="color:blue;"&gt;if &lt;/span&gt;(number.CheckRange(20.0f, 25.5f))&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;"In Range"&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color:blue;"&gt;else&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;            &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color:#a31515;"&gt;"Out of Range"&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.ReadLine();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color:blue;"&gt;static bool &lt;/span&gt;CheckRange(&lt;span style="color:blue;"&gt;this float &lt;/span&gt;num, &lt;span style="color:blue;"&gt;float &lt;/span&gt;min, &lt;span style="color:blue;"&gt;float &lt;/span&gt;max)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color:blue;"&gt;return &lt;/span&gt;num &amp;gt; min &amp;amp;&amp;amp; num &amp;lt; max;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;VB.NET&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;Module &lt;/span&gt;Module1&lt;br /&gt;    &lt;span style="color:blue;"&gt;Public Sub &lt;/span&gt;Main(&lt;span style="color:blue;"&gt;ByVal &lt;/span&gt;args() &lt;span style="color:blue;"&gt;As String&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color:blue;"&gt;Dim &lt;/span&gt;number &lt;span style="color:blue;"&gt;As Single &lt;/span&gt;= 23.5F&lt;br /&gt;        &lt;span style="color:blue;"&gt;If &lt;/span&gt;number.CheckRange(20.0F, 25.5F) &lt;span style="color:blue;"&gt;Then&lt;br /&gt;            &lt;/span&gt;Console.WriteLine(&lt;span style="color:#a31515;"&gt;"In Range"&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color:blue;"&gt;Else&lt;br /&gt;            &lt;/span&gt;Console.WriteLine(&lt;span style="color:#a31515;"&gt;"Out of Range"&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color:blue;"&gt;End If&lt;br /&gt;        &lt;/span&gt;Console.ReadLine()&lt;br /&gt;    &lt;span style="color:blue;"&gt;End Sub&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&amp;lt;System.Runtime.CompilerServices.Extension()&amp;gt; _&lt;br /&gt;    &lt;span style="color:blue;"&gt;Private Function &lt;/span&gt;CheckRange(&lt;span style="color:blue;"&gt;ByVal &lt;/span&gt;num &lt;span style="color:blue;"&gt;As Single&lt;/span&gt;, _&lt;br /&gt;                                &lt;span style="color:blue;"&gt;ByVal &lt;/span&gt;min &lt;span style="color:blue;"&gt;As Single&lt;/span&gt;, _&lt;br /&gt;                                &lt;span style="color:blue;"&gt;ByVal &lt;/span&gt;max &lt;span style="color:blue;"&gt;As Single&lt;/span&gt;) &lt;span style="color:blue;"&gt;As Boolean&lt;br /&gt;        Return &lt;/span&gt;num &amp;gt; min &lt;span style="color:blue;"&gt;AndAlso &lt;/span&gt;num &amp;lt; max&lt;br /&gt;    &lt;span style="color:blue;"&gt;End Function&lt;br /&gt;End Module&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-1903812791005428684?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/SG9BZ8JudSU" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/SG9BZ8JudSU/check-if-float-number-falls-within.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/11/check-if-float-number-falls-within.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-6664841724689328695</guid><pubDate>Tue, 03 Nov 2009 12:55:00 +0000</pubDate><atom:updated>2009-11-03T04:55:00.599-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><title>Add a DotNetKicks button to your Webpage</title><description>&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/" target="_blank"&gt;DotNetKicks&lt;/a&gt; is a popular .NET community based news site. A lot of users use the DotNetKicks social bookmarking button which makes it easier for viewers to submit or ‘kick’ a story. If you have been wondering how to add the DotNetKicks button to every post on your website, here’s the code for it. &lt;/p&gt;&lt;p&gt;&lt;span style="color:#9999ff;"&gt;&lt;em&gt;&lt;span style="color:#000000;"&gt;&amp;lt;div&amp;gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;document.write('&amp;lt;a href="http://www.dotnetkicks.com/submit?url='+document.location.href+'&amp;amp;amp;title='+document.title+'"&amp;gt; &amp;lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url='+document.location.href+'" border="0"&amp;gt;&amp;lt;/a&amp;gt;');&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This piece of code determines the URL using ‘document.location.href’ and the Title using ‘document.title’. This information is submitted to the dotnetkicks site when the user click on the link/image. When this code is placed on a page, the output generated is as shown below:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_0j4bzarlOBg/Su66K2OsnFI/AAAAAAAAAd0/AGoZFyE9Sqg/s1600-h/image%5B2%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="46" alt="image" src="http://lh5.ggpht.com/_0j4bzarlOBg/Su66MowYxkI/AAAAAAAAAd4/lukR3w0-KbQ/image_thumb.png?imgmax=800" width="107" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-6664841724689328695?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/lXMMzNtJzfM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/lXMMzNtJzfM/add-dotnetkicks-button-to-your-webpage.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/11/add-dotnetkicks-button-to-your-webpage.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-3613208137530102402</guid><pubDate>Mon, 02 Nov 2009 12:55:00 +0000</pubDate><atom:updated>2009-11-02T04:55:00.791-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><title>How to access parts of a URL in ASP.NET</title><description>&lt;p&gt;A user asked me the simplest way to dissect a URL and list down the different parts of it in ASP.NET. I advised him to use the &lt;a href="http://msdn.microsoft.com/en-us/library/system.uri.aspx" target="_blank"&gt;URI class&lt;/a&gt;. Here’s an example:&lt;/p&gt;&lt;p&gt;C#&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:#2b91af;"&gt;Uri &lt;/span&gt;someUri = Page.Request.Url;&lt;br /&gt;&lt;span style="color:blue;"&gt;string &lt;/span&gt;urlstr = &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Format(&lt;br /&gt;    &lt;span style="color:#a31515;"&gt;"AbsoluteUri: {0}&amp;lt;br/&amp;gt; Scheme: {1}&amp;lt;br/&amp;gt; Host: {2}&amp;lt;br/&amp;gt; Query: {3} "&lt;/span&gt;,&lt;br /&gt;    someUri.AbsoluteUri, someUri.Scheme, someUri.Host, someUri.Query);&lt;br /&gt;Response.Write(urlstr);&lt;/pre&gt;&lt;p&gt;VB.NET&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;Dim &lt;/span&gt;someUri &lt;span style="color:blue;"&gt;As &lt;/span&gt;Uri = Page.Request.Url&lt;br /&gt;&lt;span style="color:blue;"&gt;Dim &lt;/span&gt;urlstr &lt;span style="color:blue;"&gt;As String &lt;/span&gt;= &lt;span style="color:blue;"&gt;String&lt;/span&gt;.Format( _&lt;br /&gt;     &lt;span style="color:#a31515;"&gt;"AbsoluteUri: {0}&amp;lt;br/&amp;gt; Scheme: {1}&amp;lt;br/&amp;gt; Host: {2}&amp;lt;br/&amp;gt; Query: {3} "&lt;/span&gt;, _&lt;br /&gt;      someUri.AbsoluteUri, someUri.Scheme, someUri.Host, someUri.Query)&lt;br /&gt;Response.Write(urlstr)&lt;/pre&gt;&lt;p&gt;The output is as shown below:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_0j4bzarlOBg/Su6rZEgvYkI/AAAAAAAAAds/I_-6mAG3tks/s1600-h/image%5B3%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="215" alt="image" src="http://lh3.ggpht.com/_0j4bzarlOBg/Su6raSdLSRI/AAAAAAAAAdw/ibtzpcqMinU/image_thumb%5B1%5D.png?imgmax=800" width="444" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-3613208137530102402?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/q_wh8afctJo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/q_wh8afctJo/how-to-access-parts-of-url-in-aspnet.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/11/how-to-access-parts-of-url-in-aspnet.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-1224675370755712691</guid><pubDate>Sun, 01 Nov 2009 16:50:00 +0000</pubDate><atom:updated>2009-11-01T08:53:30.636-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><category domain="http://www.blogger.com/atom/ns#">CSS</category><title>7 Free Tools to Minify your Scripts and CSS</title><description>&lt;p&gt;I have been doing a lot of Client-Side development recently and I have found these 7 tools of great help to improve the performance of the website by ‘shrinking’ the size of JavaScript and CSS files, referenced in the site. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.crockford.com/javascript/jsmin.html"&gt;JSMin (JavaScript Minifier)&lt;/a&gt; - removes comments and unnecessary whitespace from JavaScript files&lt;/p&gt;  &lt;p&gt;&lt;a href="http://js-optimizer.sourceforge.net/"&gt;JSO (JavaScript Optimizer)&lt;/a&gt; - allows you to manage your JavaScript and CSS resources and to reduce the amount of data transfered between the server and the client.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://dean.edwards.name/packer/"&gt;Packer&lt;/a&gt; – An online JavaScript Compressor&lt;/p&gt;  &lt;p&gt;&lt;a href="http://jscompress.com/"&gt;JSCompress.com&lt;/a&gt; – Online tool that uses either JSMin or Packer to compress your files&lt;/p&gt;  &lt;p&gt;&lt;a href="http://shygypsy.com/cssCompress/"&gt;CSS Compressor&lt;/a&gt; – Online tool that compresses your CSS file&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.digitaloverload.co.uk/jsmin/"&gt;DigitalOverload JavaScript Minifier&lt;/a&gt; – Online tool that minifies your JavaScript files&lt;/p&gt;  &lt;p&gt;and finally the one I use most frequently:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://developer.yahoo.com/yui/compressor/"&gt;YUI Compressor&lt;/a&gt; – A JavaScript minifier designed to be 100% safe and yields a higher compression ratio than most other tools.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-1224675370755712691?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/BsH06Sx_uFk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/BsH06Sx_uFk/7-free-tools-to-minify-your-scripts-and.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://www.devcurry.com/2009/11/7-free-tools-to-minify-your-scripts-and.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-6830358306379478296</guid><pubDate>Sat, 31 Oct 2009 13:32:00 +0000</pubDate><atom:updated>2009-10-31T06:32:00.775-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VB.NET</category><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Find Out the Image Type without Checking its Extension</title><description>&lt;p&gt;My colleague called up with a query. His application accepted images to be uploaded to a central server. Later the application processed the images and separated them according to the Image Type. They determined the image type by checking the extension of the image uploaded –- a very common practice of detecting the image type.&lt;/p&gt;&lt;p&gt;The issue here was that some images which were actually gif’s were renamed as jpeg’s and then uploaded, which led to faulty image processing. The requirement was to determine the correct image type in the simplest possible way even if the extension was renamed. Here’s what I suggested:&lt;/p&gt;&lt;p&gt;C#&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;try&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color:#2b91af;"&gt;Image &lt;/span&gt;imgUp = &lt;span style="color:#2b91af;"&gt;Image&lt;/span&gt;.FromFile(Server.MapPath(&lt;span style="color:#a31515;"&gt;"~/images/abc.jpg"&lt;/span&gt;));&lt;br /&gt;    &lt;span style="color:blue;"&gt;if &lt;/span&gt;(imgUp.RawFormat.Equals(&lt;span style="color:#2b91af;"&gt;ImageFormat&lt;/span&gt;.Jpeg))&lt;br /&gt;        Response.Write(&lt;span style="color:#a31515;"&gt;"JPEG"&lt;/span&gt;);&lt;br /&gt;    &lt;span style="color:blue;"&gt;else if &lt;/span&gt;(imgUp.RawFormat.Equals(&lt;span style="color:#2b91af;"&gt;ImageFormat&lt;/span&gt;.Gif))&lt;br /&gt;        Response.Write(&lt;span style="color:#a31515;"&gt;"GIF"&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:blue;"&gt;catch &lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;Exception &lt;/span&gt;ex)&lt;br /&gt;{&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;VB.NET&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;Try&lt;br /&gt;    Dim &lt;/span&gt;imgUp &lt;span style="color:blue;"&gt;As &lt;/span&gt;Image = Image.FromFile(Server.MapPath("~/images/abc.jpg"))&lt;br /&gt;    &lt;span style="color:blue;"&gt;If &lt;/span&gt;imgUp.RawFormat.Equals(ImageFormat.Jpeg) &lt;span style="color:blue;"&gt;Then&lt;br /&gt;        &lt;/span&gt;Response.Write("JPEG")&lt;br /&gt;    &lt;span style="color:blue;"&gt;ElseIf &lt;/span&gt;imgUp.RawFormat.Equals(ImageFormat.Gif) &lt;span style="color:blue;"&gt;Then&lt;br /&gt;        &lt;/span&gt;Response.Write("GIF")&lt;br /&gt;    &lt;span style="color:blue;"&gt;End If&lt;br /&gt;Catch &lt;/span&gt;ex &lt;span style="color:blue;"&gt;As &lt;/span&gt;Exception&lt;br /&gt;&lt;span style="color:blue;"&gt;End Try&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/system.drawing.image.rawformat.aspx"&gt;Image.RawFormat&lt;/a&gt; property is extremely useful in this situation to get the file format of the image.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Alternatively you can also use &lt;a href="http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic%5Fnumbers%5Fin%5Ffiles"&gt;Magic Numbers&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-6830358306379478296?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/NYbJTKo12mE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/NYbJTKo12mE/find-out-image-type-without-checking.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/find-out-image-type-without-checking.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-5021926253893667349</guid><pubDate>Fri, 30 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-30T04:55:00.113-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VB.NET</category><category domain="http://www.blogger.com/atom/ns#">C#</category><title>How to calculate the CPU Usage Programmatically using C# or VB.NET</title><description>&lt;p&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.performancecounter.aspx"&gt;PerformanceCounter&lt;/a&gt; class represents a WindowsNT performance counter component. To read from a performance counter, we first create an instance of the PerformanceCounter class supplying the CategoryName, CounterName, and InstanceName as parameters to the constructor and then call the &lt;a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.performancecounter.nextvalue.aspx"&gt;NextValue&lt;/a&gt;() method to take a performance counter reading.&lt;/p&gt;&lt;p&gt;Import the namespaces System.Diagnostics and System.Threading.&lt;/p&gt;&lt;p&gt;C#&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;static &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;PerformanceCounter &lt;/span&gt;cpuUsage;&lt;br /&gt;&lt;span style="color:blue;"&gt;public static void &lt;/span&gt;Main(&lt;span style="color:blue;"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;{&lt;br /&gt;    cpuUsage =&lt;br /&gt;        &lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;PerformanceCounter&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;"Processor"&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;"% Processor Time"&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;"_Total"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(cpuUsage.NextValue() + &lt;span style="color:#a31515;"&gt;" %"&lt;/span&gt;);&lt;br /&gt;    &lt;span style="color:#2b91af;"&gt;Thread&lt;/span&gt;.Sleep(1000);&lt;br /&gt;    &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(cpuUsage.NextValue() + &lt;span style="color:#a31515;"&gt;" %"&lt;/span&gt;);&lt;br /&gt;    &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.Read();&lt;br /&gt;}&lt;/pre&gt;&lt;p&gt;VB.NET&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;Private Shared &lt;/span&gt;cpuUsage &lt;span style="color:blue;"&gt;As &lt;/span&gt;PerformanceCounter&lt;br /&gt;&lt;span style="color:blue;"&gt;Public Shared Sub &lt;/span&gt;Main(&lt;span style="color:blue;"&gt;ByVal &lt;/span&gt;args() &lt;span style="color:blue;"&gt;As String&lt;/span&gt;)&lt;br /&gt;    cpuUsage = _&lt;br /&gt;    &lt;span style="color:blue;"&gt;New &lt;/span&gt;PerformanceCounter(&lt;span style="color:#a31515;"&gt;"Processor"&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;"% Processor Time"&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;"_Total"&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(cpuUsage.NextValue() &amp;amp; &lt;span style="color:#a31515;"&gt;" %"&lt;/span&gt;)&lt;br /&gt;    Thread.Sleep(1000)&lt;br /&gt;    Console.WriteLine(cpuUsage.NextValue() &amp;amp; &lt;span style="color:#a31515;"&gt;" %"&lt;/span&gt;)&lt;br /&gt;    Console.Read()&lt;br /&gt;&lt;span style="color:blue;"&gt;End Sub&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Observe that we are calling NextValues() twice and after a delay of 1 second. This is because performance counters need two samples to perform the calculation and the counter value is updated once per second, hence the 1 second delay between the two calls.&lt;/p&gt;&lt;p&gt;The output on running this code is as shown below:&lt;/p&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_0j4bzarlOBg/Suqneao8j4I/AAAAAAAAAcw/YV0vJh-Jlo4/s1600-h/image%5B2%5D.png"&gt;&lt;img title="image" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="53" alt="image" src="http://lh4.ggpht.com/_0j4bzarlOBg/SuqnfC-VpxI/AAAAAAAAAc0/FFD2t-tmO0M/image_thumb.png?imgmax=800" width="116" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-5021926253893667349?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/XH40fpqHJbY" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/XH40fpqHJbY/how-to-calculate-cpu-usage.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/how-to-calculate-cpu-usage.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-5938691178066520708</guid><pubDate>Thu, 29 Oct 2009 15:20:00 +0000</pubDate><atom:updated>2009-10-29T08:25:00.059-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">VB.NET</category><category domain="http://www.blogger.com/atom/ns#">C#</category><title>Find Out the Users Connected to a Windows Server using C# or VB.NET</title><description>&lt;p&gt;I was recently asked this question on the forums – How do I find out and list the users connected to a server? I said use &lt;a href="http://code.google.com/p/cassia/"&gt;&lt;strong&gt;Cassia&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;A standard way of achieving this requirement is to use P/Invoke to access the Windows Terminal Services API. Cassia is a .NET library that acts as a wrapper on the native Windows Terminal Services API.  &lt;/p&gt;&lt;p&gt;Cassia has been tested on Windows Server 2008 R2 Beta, Windows Server 2008, Windows Server 2003, Windows XP, and Windows Server 2000. It should work on Windows Vista as well. I haven’t tried it on Windows 7. If any of you does, kindly drop in a comment and let the users know of your experience.&lt;/p&gt;&lt;p&gt;Check out &lt;a href="http://code.google.com/p/cassia/"&gt;Cassia&lt;/a&gt;!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-5938691178066520708?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/qgxpnhiB2sA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/qgxpnhiB2sA/find-out-users-connected-to-windows.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/find-out-users-connected-to-windows.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-5439652527168253549</guid><pubDate>Wed, 28 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-28T05:33:05.423-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Screencast</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Inject jQuery into a webpage using a FireFox addon - FireQuery</title><description>&lt;p&gt;I found a really cool Firefox addon called &lt;a href="http://firequery.binaryage.com/"&gt;FireQuery&lt;/a&gt;. This addon enables you to inject jQuery into any web page. This is a nice way to see how any web page behaves with jQuery. &lt;/p&gt;&lt;p&gt;Normally I would write a small article on how to use this technology, but I felt like doing something different so I made a short screencast on FireQuery and how to use it. Hopefully you’ll find it a useful tool as well.&lt;/p&gt;&lt;p&gt;You can watch the screencast &lt;a href="http://www.youtube.com/watch?v=yeMCopPfy4w"&gt;here&lt;/a&gt; or can see it below:&lt;/p&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/yeMCopPfy4w&amp;amp;hl=en&amp;amp;fs=1&amp;amp;"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/yeMCopPfy4w&amp;amp;hl=en&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-5439652527168253549?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/2thrQ3m2X38" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/2thrQ3m2X38/inject-jquery-into-webpage-using.html</link><author>noreply@blogger.com (Malcolm Sheridan)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/inject-jquery-into-webpage-using.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-6187589768668722067</guid><pubDate>Wed, 28 Oct 2009 00:08:00 +0000</pubDate><atom:updated>2009-10-27T22:35:12.095-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><title>ASP.NET 4.0 (Beta) Resources</title><description>&lt;p&gt;Here are some useful resources to get started with the latest version of ASP.NET 4.0. Currently ASP.NET 4.0 is in Beta 2&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.devcurry.com/2009/10/visual-studio-2010-and-net-framework-4.html"&gt;ASP.NET 4.0 and Visual Studio 2010 Beta 2 Released&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.asp.net/Learn/whitepapers/aspnet4/default.aspx"&gt;ASP.NET 4 and Visual Studio 2010 Web Development Beta 2 Overview&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://channel9.msdn.com/learn/courses/VS2010/ASPNET/"&gt;ASP.NET 4.0 Training Lessons on Channel 9&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/ee431529.aspx"&gt;Exploring ASP.NET 4.0—Web Forms and Beyond&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx"&gt;URL Routing with ASP.NET 4 Web Forms (VS 2010 and .NET 4.0 Series)&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx"&gt;Auto-Start ASP.NET Applications (VS 2010 and .NET 4.0 Series)&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.hanselman.com/blog/TheMinutesOn9Channel9VideoInterviewsWithTheASPNET4Team.aspx"&gt;Channel 9 Video Interviews with the ASP.NET 4 Team&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://forums.asp.net/1212.aspx"&gt;ASP.NET 4 Beta 2 forums&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-6187589768668722067?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/6rGybF8j8fE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/6rGybF8j8fE/aspnet-40-beta-resources.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/aspnet-40-beta-resources.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-6585509636530481175</guid><pubDate>Mon, 26 Oct 2009 23:47:00 +0000</pubDate><atom:updated>2009-10-26T21:49:27.317-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>5 jQuery Plugins to Manipulate and add effects to Images</title><description>&lt;p&gt;Here is a list of 5 plugins you can use to manipulate images on client-side. This section has been taken from my eBook &lt;a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=403"&gt;&lt;strong&gt;51 Tips, Tricks and Recipes using jQuery and ASP.NET Controls&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://plugins.jquery.com/project/jQueryImageOverlay"&gt;ImageOverlay&lt;/a&gt; - Allows you to display additional information in a translucent pane above an image that gracefully appears when a user hovers over the image&lt;/p&gt;  &lt;p&gt;&lt;a href="http://plugins.jquery.com/project/Jcrop"&gt;jCrop&lt;/a&gt; - jCrop is the quick and easy way to add image cropping functionality to your web application. It combines the ease-of-use of a typical jQuery plugin with a powerful cross-platform DHTML cropping engine that is faithful to familiar desktop graphics applications.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://plugins.jquery.com/project/jLoupe"&gt;jLoupe&lt;/a&gt; - jLoupe adds a &amp;quot;loupe&amp;quot; or &amp;quot;magnifying glass&amp;quot; effect to images. Applying the plugin is as easy as adding the class &amp;quot;jLoupe&amp;quot; to the images you want to enable the effect on.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://plugins.jquery.com/project/magnify"&gt;Magnify&lt;/a&gt; - Magnify allows you to easily create a &amp;quot;magnifier&amp;quot; on your images. You just need to create a small and large image which are proportionally sized, configure your markup accordingly and let Magnify do the rest&lt;/p&gt;  &lt;p&gt;&lt;a href="http://plugins.jquery.com/project/reel"&gt;Reel&lt;/a&gt; - Reel is a jQuery plugin which takes an image tag and makes it a live &amp;quot;projection&amp;quot; of pre-built animation frames sequence. Its aim is to provide a 360° view of something or someplace. Like a turntable or a panorama for instance&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-6585509636530481175?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/Dxn9VP4qnoo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/Dxn9VP4qnoo/5-jquery-plugins-to-manipulate-and-add.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/5-jquery-plugins-to-manipulate-and-add.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-8306577179969477311</guid><pubDate>Mon, 26 Oct 2009 00:30:00 +0000</pubDate><atom:updated>2009-10-25T22:32:24.336-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Misc Ramblings</category><title>14 Expression Web 3 Tips and Articles</title><description>&lt;p&gt;If you use Expressions Web 3, check out a link list by Expression Web MVP Minal where she has written some useful Expression Web 3 tips and tricks&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=405"&gt;14 Microsoft Expression Web 3 Articles and Tips you should read&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here’s an excerpt&lt;/p&gt;  &lt;blockquote&gt;   &lt;p align="justify"&gt;&lt;a href="http://www.microsoft.com/Expression/try-it/default.aspx#PageTop"&gt;Microsoft Expression Web&lt;/a&gt; is a ’WYSIWYG’ HTML editor as well as a graphical web design program developed by Microsoft that has today replaced Microsoft FrontPage. Expression Web is a part of the Expression Studio suite. Expression Web provides support for integrating XML, XHTML, XSLT, CSS, ASP.NET and other standard Web technologies into the websites.&lt;/p&gt;    &lt;p align="justify"&gt;I have been using Microsoft Expression Web 2 for quite some time now and I love it! Now with release of Expression Web 3, with features like SuperPreview, Snapshot Panel, new improved toolbars like the Code Toolbar, integration with VSTS, Silverlight support and an enhanced FTP client, you get a better control over your web pages. Believe me, designing has never been so simple and interesting before.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You can also read some additional &lt;a href="http://saffronstroke.com/expression-web-tips/"&gt;Tips on Microsoft Expression Web 2&lt;/a&gt; and &lt;a href="http://dotnetcurry.com/BrowseArticles.aspx?CatID=48"&gt;Tutorials on Microsoft Expression Web 2&lt;/a&gt; written by Minal&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-8306577179969477311?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/Cc_Zrws3dI8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/Cc_Zrws3dI8/14-expression-web-3-tips-and-articles.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/14-expression-web-3-tips-and-articles.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-8680127601416641298</guid><pubDate>Sat, 24 Oct 2009 23:05:00 +0000</pubDate><atom:updated>2009-10-24T19:09:01.595-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Product Releases</category><category domain="http://www.blogger.com/atom/ns#">Visual Studio</category><title>Visual Studio 2010 and .NET Framework 4 Beta 2 Released</title><description>&lt;p&gt;Microsoft recently announced (21st October) the immediate availability of Microsoft Visual Studio 2010 Beta 2 and Microsoft .NET Framework 4 Beta 2 to general public &lt;/p&gt;  &lt;p&gt;Here are some important links related to the release&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;Visual Studio 2010 Beta 2 including Express downloads&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/shows/10-4/10-4-Episode-33-Downloading-and-Installing-Visual-Studio-2010-Beta-2/"&gt;Channel 9 Video: How to Install the Beta&lt;/a&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=752CB725-969B-4732-A383-ED5740F02E93&amp;amp;displaylang=en"&gt;Visual Studio 2010 and .NET Framework 4 Training Kit - October Preview&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd441784.aspx"&gt;Featured Overviews and Walkthroughs&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;Other important information&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-8680127601416641298?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/oyfaFWhMdBQ" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/oyfaFWhMdBQ/visual-studio-2010-and-net-framework-4.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/visual-studio-2010-and-net-framework-4.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-5832308530796876366</guid><pubDate>Sat, 24 Oct 2009 00:40:00 +0000</pubDate><atom:updated>2009-10-23T21:45:45.412-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Silverlight</category><title>Silverlight Toolkit October 2009 Released</title><description>&lt;p&gt;Microsoft has released a new set of Silverlight components and features in the &lt;a href="http://silverlight.codeplex.com/"&gt;Silverlight Toolkit&lt;/a&gt; (October 2009).&lt;/p&gt;  &lt;p&gt;A prominent change i found was the support for Visual Studio 2010 and drag &amp;amp; drop support for some key controls.&lt;/p&gt;  &lt;p&gt;Here are some important links related to the download:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30514"&gt;Silverlight Toolkit October 2009&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://silverlight.codeplex.com/wikipage?title=Silverlight%20Toolkit%20October%202009%20change%20list"&gt;Silverlight Toolkit October 2009 change list&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html"&gt;Online Silverlight 3 Toolkit samples&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-5832308530796876366?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/AXBqppe01uI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/AXBqppe01uI/silverlight-toolkit-october-2009.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/silverlight-toolkit-october-2009.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-3422396938339281361</guid><pubDate>Thu, 22 Oct 2009 23:09:00 +0000</pubDate><atom:updated>2009-10-22T21:11:48.672-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Windows 7</category><category domain="http://www.blogger.com/atom/ns#">Product Releases</category><title>Windows 7 Launched!</title><description>&lt;p&gt;The much awaited &lt;a href="http://www.microsoft.com/windows/windows-7/what-is-windows-7.aspx"&gt;&lt;strong&gt;Windows 7 OS&lt;/strong&gt;&lt;/a&gt; was launched today in a keynote by Microsoft’s Chief Executive Steve Ballmer &lt;/p&gt;  &lt;p&gt;Here are some useful links:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/windows/windows-7/compare/32-bit-64-bit-faq.aspx"&gt;Read the 32-bit and 64-bit Windows FAQ.&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/windows/windows-7/compare/upgrade-from-vista.aspx"&gt;Top 10 reasons to upgrade to Windows 7 &lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/windows/windows-7/compare/default.aspx"&gt;Choose the Windows 7 Edition&lt;/a&gt; that works best for you.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.microsoft.com/windows/offers/7-days/"&gt;Daily Offers&lt;/a&gt; till October 28th, 2009&lt;/p&gt;  &lt;h4&gt;Purchase it on Amazon&lt;/h4&gt; &lt;a href="http://www.amazon.com/gp/product/B002DHLUWK?ie=UTF8&amp;amp;tag=dotcomandsqlc-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B002DHLUWK"&gt;Microsoft Windows 7 Home Premium Upgrade&lt;/a&gt;&lt;img style="margin: 0px; border-top-style: none! important; border-right-style: none! important; border-left-style: none! important; border-bottom-style: none! important" height="1" alt="" src="http://www.assoc-amazon.com/e/ir?t=dotcomandsqlc-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B002DHLUWK" width="1" border="0" /&gt;   &lt;br /&gt;&lt;a href="http://www.amazon.com/gp/product/B002DHGM50?ie=UTF8&amp;amp;tag=dotcomandsqlc-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B002DHGM50"&gt;Microsoft Windows 7 Professional Upgrade&lt;/a&gt;&lt;img style="margin: 0px; border-top-style: none! important; border-right-style: none! important; border-left-style: none! important; border-bottom-style: none! important" height="1" alt="" src="http://www.assoc-amazon.com/e/ir?t=dotcomandsqlc-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B002DHGM50" width="1" border="0" /&gt;   &lt;br /&gt;&lt;a href="http://www.amazon.com/gp/product/B002DHLV8S?ie=UTF8&amp;amp;tag=dotcomandsqlc-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B002DHLV8S"&gt;Microsoft Windows 7 Ultimate Upgrade&lt;/a&gt;&lt;img style="margin: 0px; border-top-style: none! important; border-right-style: none! important; border-left-style: none! important; border-bottom-style: none! important" height="1" alt="" src="http://www.assoc-amazon.com/e/ir?t=dotcomandsqlc-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B002DHLV8S" width="1" border="0" /&gt;   &lt;br /&gt;&lt;a href="http://www.amazon.com/gp/product/B002DHGMK0?ie=UTF8&amp;amp;tag=dotcomandsqlc-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B002DHGMK0"&gt;Microsoft Windows 7 Home Premium&lt;/a&gt;&lt;img style="margin: 0px; border-top-style: none! important; border-right-style: none! important; border-left-style: none! important; border-bottom-style: none! important" height="1" alt="" src="http://www.assoc-amazon.com/e/ir?t=dotcomandsqlc-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B002DHGMK0" width="1" border="0" /&gt;   &lt;br /&gt;&lt;a href="http://www.amazon.com/gp/product/B002DHGMVY?ie=UTF8&amp;amp;tag=dotcomandsqlc-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B002DHGMVY"&gt;Microsoft Windows 7 Ultimate&lt;/a&gt;&lt;img style="margin: 0px; border-top-style: none! important; border-right-style: none! important; border-left-style: none! important; border-bottom-style: none! important" height="1" alt="" src="http://www.assoc-amazon.com/e/ir?t=dotcomandsqlc-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B002DHGMVY" width="1" border="0" /&gt;   &lt;br /&gt;&lt;a href="http://www.amazon.com/gp/product/B002DHLVII?ie=UTF8&amp;amp;tag=dotcomandsqlc-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B002DHLVII"&gt;Microsoft Windows 7 Professional&lt;/a&gt;&lt;img style="margin: 0px; border-top-style: none! important; border-right-style: none! important; border-left-style: none! important; border-bottom-style: none! important" height="1" alt="" src="http://www.assoc-amazon.com/e/ir?t=dotcomandsqlc-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B002DHLVII" width="1" border="0" /&gt;&lt;br /&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-3422396938339281361?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/xm-oRAD5XhE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/xm-oRAD5XhE/windows-7-launched.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/windows-7-launched.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-345843571064637575</guid><pubDate>Wed, 21 Oct 2009 17:17:00 +0000</pubDate><atom:updated>2009-10-21T10:22:14.094-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>51 Tips, Tricks and Recipes with jQuery and ASP.NET Controls eBook Released!</title><description>&lt;p&gt;I am glad to announce the release of my eBook &lt;b&gt;51 Tips, Tricks and Recipes with jQuery and ASP.NET Controls&lt;/b&gt;. In the first book of its kind on using jQuery with ASP.NET Controls, I show you how to use jQuery to solve some common and not-so-common client-side programming challenges while dealing with ASP.NET Controls. &lt;/p&gt;  &lt;p&gt;You can download the &lt;a href="http://www.scribd.com/doc/20458606/51-Recipes-With-jQuery-and-ASP-NET-Controls-Preview"&gt;Table of Contents and 5 Sample Chapters of the eBook&lt;/a&gt; before buying. &lt;/p&gt;  &lt;p&gt;You can &lt;a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=403"&gt;purchase the eBook over here&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-345843571064637575?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/m-AeL-Id_Jo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/m-AeL-Id_Jo/51-tips-tricks-and-recipes-with-jquery.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/51-tips-tricks-and-recipes-with-jquery.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-5168981647799872480</guid><pubDate>Tue, 20 Oct 2009 14:16:00 +0000</pubDate><atom:updated>2009-10-20T07:18:20.030-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Last Chance to Pre-Order my EBook – 51 Recipes with jQuery and ASP.NET Controls</title><description>&lt;p&gt;If you have not yet pre-ordered my EBook - &lt;b&gt;&lt;a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=393" target="_blank"&gt;51 Tips, Tricks and Recipes with jQuery and ASP.NET Controls&lt;/a&gt;&lt;/b&gt;, then here’s the last chance to pre-order the EBook at a discounted price. This offer will expire in &lt;strong&gt;13 hours&lt;/strong&gt; from now! &lt;/p&gt;&lt;p&gt;The EBook will be released tomorrow (October 21st, 2009).  &lt;/p&gt;&lt;p&gt;You can download the &lt;a href="http://www.scribd.com/doc/20458606/51-Recipes-With-jQuery-and-ASPnet-Preview"&gt;&lt;strong&gt;Table of Contents and 5 Sample Chapters&lt;/strong&gt;&lt;/a&gt; of the upcoming EBook before purchasing.&lt;/p&gt;&lt;p&gt;Pre-Order the EBook&lt;a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=393"&gt; &lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=393"&gt;&lt;img title="Ebook" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="244" alt="Ebook" src="http://lh5.ggpht.com/_0j4bzarlOBg/St3GQRNeThI/AAAAAAAAAcs/LRmg_TBAn_0/Ebook%5B3%5D.jpg?imgmax=800" width="167" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-5168981647799872480?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/dNRZWY2cpTk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/dNRZWY2cpTk/last-chance-to-pre-order-my-ebook-51.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/last-chance-to-pre-order-my-ebook-51.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-5083437732043402357</guid><pubDate>Mon, 19 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-19T04:55:00.488-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><title>Display Currency Symbols using ISO standards in ASP.NET</title><description>&lt;p&gt;I stumbled across an interesting question about localization/globalization recently. The user wanted to print currency symbols using the &lt;a href="http://www.iso.org/iso/currency_codes_list-1" target="_blank"&gt;ISO&lt;/a&gt; standards and wanted to find out if there was an easy way to do so using ASP.NET&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Yes, there is! Use the &lt;a href="http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.isocurrencysymbol.aspx" target="_blank"&gt;RegionInfo.ISOCurrencySymbol&lt;/a&gt; Property. Here’s how&lt;/p&gt;&lt;br /&gt;&lt;p&gt;C#&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;string &lt;/span&gt;symbol = &lt;span style="color:#2b91af;"&gt;RegionInfo&lt;/span&gt;.CurrentRegion.ISOCurrencySymbol;&lt;br /&gt;&lt;br /&gt;Response.Write(symbol);&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;VB.NET&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;Dim &lt;/span&gt;symbol &lt;span style="color:blue;"&gt;As String &lt;/span&gt;= RegionInfo.CurrentRegion.ISOCurrencySymbol&lt;br /&gt;&lt;br /&gt;Response.Write(symbol)&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;The output on my system is &lt;strong&gt;USD&lt;/strong&gt;, which is according to the &lt;a href="http://www.iso.org/iso/currency_codes_list-1" target="_blank"&gt;ISO 4217&lt;/a&gt; standards&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-5083437732043402357?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/uwKFITCtyd4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/uwKFITCtyd4/display-currency-symbols-using-iso.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/display-currency-symbols-using-iso.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-7975471140680113983</guid><pubDate>Sun, 18 Oct 2009 11:55:00 +0000</pubDate><atom:updated>2009-10-18T05:02:53.145-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET AJAX</category><title>Microsoft Ajax Library Preview 6 and Ajax Minifier</title><description>&lt;p&gt;Microsoft recently announced a &lt;a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=34488" target="_blank"&gt;new update&lt;/a&gt; to Microsoft Ajax Library (Preview 6) and introduced the Microsoft Ajax Minifier.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;What is the Ajax Library Preview 6?&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The Ajax Library is a pure JavaScript library that enables you to build highly interactive Ajax applications. You can use the Microsoft Ajax Library in both ASP.NET Web Forms and ASP.NET MVC applications and this library works with most of the modern browsers&lt;/p&gt;&lt;p&gt;&lt;strong&gt;What is Ajax Minifier?&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;In simple words, this tool improves the performance of your websites by reducing the size of your JavaScript files&lt;/p&gt;&lt;p&gt;Here are some important links to help you out with this new update&lt;/p&gt;&lt;p&gt;&lt;a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=34488" target="_blank"&gt;Microsoft Ajax Library Preview 6&lt;/a&gt; - Download link&lt;/p&gt;&lt;p&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/15/announcing-microsoft-ajax-library-preview-6-and-the-microsoft-ajax-minifier.aspx" target="_blank"&gt;Announcing Microsoft Ajax Library (Preview 6) and the Microsoft Ajax Minifier&lt;/a&gt; - ScottGu’s blog&lt;/p&gt;&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/jsenior/Announcing-Microsoft-Ajax-Library-Preview-6/"&gt;Announcing Microsoft Ajax Library Preview 6&lt;/a&gt; - Channel 9&lt;/p&gt;&lt;p&gt;&lt;a href="http://weblogs.asp.net/bleroy/archive/2009/10/15/entirely-unobtrusive-and-imperative-templates-with-microsoft-ajax-4-preview-6.aspx" target="_blank"&gt;Entirely unobtrusive and imperative templates with Microsoft Ajax Library Preview 6&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-7975471140680113983?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/CmFTZnlD6dI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/CmFTZnlD6dI/microsoft-ajax-library-preview-6-and.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/microsoft-ajax-library-preview-6-and.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-7623861638059936566</guid><pubDate>Sat, 17 Oct 2009 23:33:00 +0000</pubDate><atom:updated>2009-10-19T07:37:03.882-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Product Releases</category><category domain="http://www.blogger.com/atom/ns#">Misc Ramblings</category><title>Let Me Bing That For You – New Service announcement</title><description>&lt;p&gt;Many a times on the forums, I have seen users ask very basic questions that can easily be ‘searched out’. Answerers usually respond to these basic question by guiding the original poster to a search engine and tell them what to search. WAWOT (What a waste of time!)&lt;/p&gt;&lt;p&gt;Here’s how you can now help this OP with some style. Many of you must be familiar with &lt;a href="http://lmgtfy.com/" target="_blank"&gt;lmgtfy.com&lt;/a&gt; or &lt;a href="http://lmgtfy.com/" target="_blank"&gt;Let me Google that for you&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://blog.maartenballiauw.be/"&gt;Maarten Balliauw&lt;/a&gt;, &lt;a href="http://hanssens.org/"&gt;Juliën Hanssens&lt;/a&gt; and &lt;a href="http://haacked.com/Default.aspx" target="_blank"&gt;Phil Haack&lt;/a&gt; got together and created a new website called &lt;a href="http://letmebingthatforyou.com/" target="_blank"&gt;Let Me Bing That For You&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;a href="http://letmebingthatforyou.com/" target="_blank"&gt;Let Me Bing That For You&lt;/a&gt; is a service for our lazy friends who are just too lazy to search out for answers on their own. Here’s how the service works. Assuming the user asked you a query ‘How to lose your Job’. Here’s how you can teach him how to search&lt;/p&gt;&lt;p&gt;- Go to &lt;a href="http://letmebingthatforyou.com/" target="_blank"&gt;Let Me Bing That For You&lt;/a&gt;&lt;/p&gt;&lt;p&gt;- Type in the users query ‘How to lose your Job’ in the search box and click the search button&lt;/p&gt;&lt;p&gt;- The service provides you a link to pass on to that lazy bum&lt;/p&gt;&lt;p&gt;The link guides the user step by step on how to Bing that query. Check the results here :)&lt;/p&gt;&lt;p&gt;&lt;a href="http://tinyurl.com/yfd4vbd"&gt;http://tinyurl.com/yfd4vbd&lt;/a&gt;&lt;a title="http://tinyurl.com/ygbhgp2" href="http://tinyurl.com/ygbhgp2"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Go Search Go!!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-7623861638059936566?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/cLVYmTk6MQM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/cLVYmTk6MQM/let-me-bing-that-for-you-new-service.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/let-me-bing-that-for-you-new-service.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8980734269859237005.post-9112994090541538768</guid><pubDate>Fri, 16 Oct 2009 13:55:00 +0000</pubDate><atom:updated>2009-10-16T06:59:11.632-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Allow Only Alphanumeric Characters in a TextBox using jQuery</title><description>&lt;p&gt;In this short post, I will demonstrate how to allow only alphanumeric characters in a TextBox. This article is a sample chapter from my upcoming EBook called &lt;a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=393"&gt;&lt;b&gt;51 Tips, Tricks and Recipes with jQuery and ASP.NET Controls&lt;/b&gt;&lt;/a&gt;. The chapter content has been modified a little to publish it as a blog post. Also please note that for demonstration purposes, I have included JavaScript and CSS into the same file. Ideally, these resources should be created in separate folders for maintainability.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Requirement:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Users should be allowed to enter only Alphabets and Numbers in a TextBox. Non-alphanumeric characters should be disallowed. You also want to prevent users from copying and pasting non-alphanumeric characters into the TextBox.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;html &lt;/span&gt;&lt;span style="color:red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;head &lt;/span&gt;&lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;="Head1" &lt;/span&gt;&lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;title&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;Allow Only Alphanumeric Characters in a TextBox&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;title&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;link &lt;/span&gt;&lt;span style="color:red;"&gt;href&lt;/span&gt;&lt;span style="color:blue;"&gt;="../CSS/Demos.css" &lt;/span&gt;&lt;span style="color:red;"&gt;rel&lt;/span&gt;&lt;span style="color:blue;"&gt;="stylesheet" &lt;/span&gt;&lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;="text/css" /&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script &lt;/span&gt;&lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;='text/javascript'&lt;br /&gt;        &lt;/span&gt;&lt;span style="color:red;"&gt;src&lt;/span&gt;&lt;span style="color:blue;"&gt;='../Scripts/jquery-1.3.2.min.js'&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;  &lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script &lt;/span&gt;&lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;="text/javascript"&amp;gt;&lt;br /&gt;        &lt;/span&gt;$(&lt;span style="color:blue;"&gt;function&lt;/span&gt;() {&lt;br /&gt;            $(&lt;span style="color:#a31515;"&gt;'input.alpha[$id=tb1]'&lt;/span&gt;).keyup(&lt;span style="color:blue;"&gt;function&lt;/span&gt;() {&lt;br /&gt;                &lt;span style="color:blue;"&gt;if &lt;/span&gt;(&lt;span style="color:blue;"&gt;this&lt;/span&gt;.value.match(/[^a-zA-Z0-9 ]/g)) {&lt;br /&gt;                    &lt;span style="color:blue;"&gt;this&lt;/span&gt;.value = &lt;span style="color:blue;"&gt;this&lt;/span&gt;.value.replace(/[^a-zA-Z0-9 ]/g, &lt;span style="color:#a31515;"&gt;''&lt;/span&gt;);&lt;br /&gt;                }&lt;br /&gt;            });&lt;br /&gt;        });&lt;br /&gt;    &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;head&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;body&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;form &lt;/span&gt;&lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;="form1" &lt;/span&gt;&lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;="bigDiv"&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;h2&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;Allow Only Alphanumeric Characters in a TextBox&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;h2&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TextBox &lt;/span&gt;&lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="tb1" &lt;/span&gt;&lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server" &lt;/span&gt;&lt;span style="color:red;"&gt;class&lt;/span&gt;&lt;span style="color:blue;"&gt;="alpha"&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:red;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;="Try entering Non alphanumeric char"&lt;br /&gt;            &lt;/span&gt;&lt;span style="color:red;"&gt;ToolTip&lt;/span&gt;&lt;span style="color:blue;"&gt;="Try entering Non alphanumeric char"/&amp;gt;&lt;br /&gt;         &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;br &lt;/span&gt;&lt;span style="color:blue;"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;br &lt;/span&gt;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;br /&gt;         &lt;/span&gt;Tip: Examples of some non-alphanumeric characters &lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;br &lt;/span&gt;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;br /&gt;         &lt;/span&gt;are ~!@~#$%^&amp;amp;* and so on.&lt;br /&gt;    &lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;form&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;body&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;html&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;b&gt;Explanation:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;The code shown above matches a regular expression &lt;i&gt;/[^a-zA-Z0-9 ]/g&lt;/i&gt; that finds all characters that are not alphabets or numbers. If the user enters a character that is an alphabet or number, the character is replaced with an empty string. Observe the space after ‘9’ to allow whitespaces. Since we are capturing the keyup event, we are also preventing copying and pasting of non-alphanumeric characters. I have observed people using the keypress event to handle this requirement, but remember that in IE, keypress does not behave as expected for non-character keys.&lt;/p&gt;&lt;p&gt;As &lt;a href="http://www.yehudakatz.com/"&gt;Yehuda Katz&lt;/a&gt; says – “&lt;i&gt;My mantra has always been: keydown/keyup if you want to know the key that was pressed; keypress if you want to know what text was detected&lt;/i&gt;”&lt;/p&gt;&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; Javascript can be disabled, so always validate the user input on server side&lt;/p&gt;&lt;p&gt;&lt;i&gt;Tip:&lt;/i&gt; If you want to accept only numbers, use &lt;i&gt;/[^0-9 ]/g &lt;/i&gt;and for accepting only alphabets, use &lt;i&gt;/[^a-zA-Z ]/g&lt;/i&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Browsers Supported:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;IE 7, IE 8, Firefox 3, Chrome 2, Safari 4&lt;/p&gt;&lt;p&gt;&lt;b&gt;Useful Links:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://ejohn.org/blog/keypress-in-safari-31/"&gt;http://ejohn.org/blog/keypress-in-safari-31/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://docs.jquery.com/Events/keyup"&gt;http://docs.jquery.com/Events/keyup&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.dotnetcurry.com/Demos/jQueryAlphaNumeric/OnlyAlphaNumeric.aspx" target="_blank"&gt;&lt;strong&gt;LIVE DEMO&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;There are plenty of such similar tips that I will be covering in my upcoming EBook over here &lt;a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=393"&gt;&lt;b&gt;51 Tips, Tricks and Recipes with jQuery and ASP.NET Controls&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8980734269859237005-9112994090541538768?l=www.devcurry.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/devcurry/~4/91BWmG4YUM4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/devcurry/~3/91BWmG4YUM4/allow-only-alphanumeric-characters-in.html</link><author>noreply@blogger.com (Suprotim Agarwal)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://www.devcurry.com/2009/10/allow-only-alphanumeric-characters-in.html</feedburner:origLink></item></channel></rss>
