<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5430732659644493117</id><updated>2011-04-21T19:07:20.894-07:00</updated><category term='C#'/><category term='PHP'/><category term='LINQ'/><category term='Visual Studio'/><category term='Vista'/><category term='jQuery'/><category term='MVC'/><category term='Performance'/><category term='Architecture'/><category term='SQL'/><category term='Selenium'/><category term='AJAX'/><category term='Lifestyle'/><category term='Volta'/><category term='Workflow'/><category term='JavaScript'/><category term='Azure'/><category term='Look and Feel'/><category term='Test'/><category term='.NET'/><category term='ASP.NET'/><title type='text'>Tanzim Saqib on .NET discovery</title><subtitle type='html'>Tanzim Saqib is a Senior Developer, who spent half of his life on software and worked for many companies like #1 .NET controls provider Telerik Inc, #1 personalized Web 2.0 start-page like Pageflakes (acquired by LiveUniverse). He developed many projects ranging from banking solutions for Citibank, HSBC, Wamu, Wells Fargo etc. to Paperless Virtual University. He is industry’s earliest and leading widget developer and as know as “Widget Master” to his peers.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>41</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-7910187809425490675</id><published>2008-11-19T02:12:00.001-08:00</published><updated>2008-11-19T02:12:04.770-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>CallQueue: Implementing a Sequential Web Service Call Queue for AJAX application</title><content type='html'>&lt;p&gt;In AJAX based applications its common that user might end up breaking your AJAX calls by clicking on numerous places in very short interval of time. Let us assume there is a page where there are several of hyperlinks which make WebService calls and do some stuffs on callback. If user clicks on five hyperlinks being impatient or may be just for fun, there will be five different WebService calls made. All of those calls had the same parameters or UI state while they were invoked. But on completion of one or more WebService calls it may happen that the UI state or data passed to the rest of the WebServices calls no longer exist or expired, thus will be result in inconsistent UI behaviour and/or invalid data. This is one of the important scenarios an AJAX developer should consider when he designs an application. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Specification      &lt;br /&gt;&lt;/strong&gt;To address the scenario, I would prefer implementing a Sequential WebService Calls Queue which will be able to schedule the tasks/WebService calls and help keeping UI and data consistent over the AJAX calls. We should achieve the following features from this queue:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Enqueue any WebService call anytime in the application. &lt;/li&gt;    &lt;li&gt;Dequeue any previously queued call regardless of currently executing call and location in the application. &lt;/li&gt;    &lt;li&gt;Each WebService call should have an identifier so that we can track the call and dequeue anytime later by SSQ.dq(call_id). &lt;/li&gt;    &lt;li&gt;Each call should have a timeout value which will determine the maximum amount of time we will consider for that particular call before we invoke the next call, after that we will remove from the queue. &lt;/li&gt;    &lt;li&gt;A timer will act as scheduler but will not run forever. It should run only when necessary. &lt;/li&gt;    &lt;li&gt;Each call should be able to declare its completion at any time by notifyCompleted, so that the scheduler timer will not wait for the prior task and should dequeue the next call. &lt;/li&gt;    &lt;li&gt;notifyCompleted should also be optional. The currently running call should automatically be dequeued from the scheduler queue after the timeout of its own. &lt;/li&gt;    &lt;li&gt;Each call should be able to mark as replaceIfExists so that if user`s any activity already enqueued this call, should be replaced by the current one. &lt;/li&gt;    &lt;li&gt;The queue instance should be exclusively available to the user and all over the page, meaning that the same queue class will be used to serve the functionality in one page per user basis. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;The Usage      &lt;br /&gt;&lt;/strong&gt;You should be able to use this library as follows:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Include GenericQueue.js and SequentialServiceQueue.js to your project &lt;/li&gt;    &lt;li&gt;Add the reference in the pages that you want them to be used &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;We will be naming the class as SequentialServiceQueue and in short SSQ. Let us have a look at the WebService calls in Service Queue fashion:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:fc2046a6-27d0-4752-a768-75c189e3c3e0" class="wlWriterSmartContent"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; id1 &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; SSQ.nq(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;SomeMethod1&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;false&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #000000;"&gt;1000&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;() &lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Do some stuffs&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        SomeWebService1.SomeMethod1(SomeParameters, onSomeMethodCallCompleted);&lt;br /&gt;    });&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt; onSomeMethodCallCompleted(result)&lt;br /&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Do stuffs&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    SSQ.notifyCompleted(id1);    &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; id2 &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; SSQ.nq(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;SomeMethod2&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;false&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #000000;"&gt;1000&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;() &lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Do some stuffs&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        SomeWebService2.SomeMethod2(SomeParameters, &lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;(result)&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Do stuffs&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;                SSQ.notifyCompleted(id2);&lt;br /&gt;            });&lt;br /&gt;    });&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You can not only queue WebService calls, but also regular JavaScript codeblock:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; width: 619px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:6d67a192-97a6-4b98-a8d5-a17decee5809" class="wlWriterSmartContent"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; service_id1 &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; SSQ.nq(&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;Service1&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;false&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #000000;"&gt;1000&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;() &lt;br /&gt;    {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Do some stuffs&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;        SSQ.notifyCompleted(service_id1);&lt;br /&gt;    });&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;The GenericQueue &lt;br /&gt;    &lt;br /&gt;&lt;/strong&gt;To accomplish the SequentialServiceQueue, first of all we should define an all purpose GenericQueue class which will able to handle any queue requirement out of the box. The queue is fairly simple, just like old Computer Science data structure class. Here are few of the functions from the class:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:3376f21b-d36c-474a-9973-b2befdf1374e" class="wlWriterSmartContent"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.nq &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;(element) &lt;br /&gt;{&lt;br /&gt;    array.push(element);&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #000000;"&gt;++&lt;/span&gt;&lt;span style="color: #000000;"&gt;rear;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.dq &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;() &lt;br /&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; element &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; undefined;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #000000;"&gt;!&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.is_empty()) &lt;br /&gt;    {&lt;br /&gt;        element &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; array.shift();&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #000000;"&gt;--&lt;/span&gt;&lt;span style="color: #000000;"&gt;rear;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; element;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.for_each &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;(func)&lt;br /&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;for&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; i &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;; i &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; rear; &lt;/span&gt;&lt;span style="color: #000000;"&gt;++&lt;/span&gt;&lt;span style="color: #000000;"&gt;i)&lt;br /&gt;        func(i, array[i]);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.delete_at &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;(index) &lt;br /&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;delete&lt;/span&gt;&lt;span style="color: #000000;"&gt; array[index];&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; i &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; index;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;while&lt;/span&gt;&lt;span style="color: #000000;"&gt; (i &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; array.length) &lt;br /&gt;        array[i] &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; array[&lt;/span&gt;&lt;span style="color: #000000;"&gt;++&lt;/span&gt;&lt;span style="color: #000000;"&gt;i];&lt;br /&gt;&lt;br /&gt;    array &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; array.slice(&lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #000000;"&gt;--&lt;/span&gt;&lt;span style="color: #000000;"&gt;rear);&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;The SequentialServiceQueue&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;The following is how this class starts. You will notice here that the timer_id is for our scheduler timer, running_task indicates the currently executing call, interval is a variable for the timer_id which you can determine as your wish. interval is the knob of how fast or slow you want the scheduler to run. queue as you can understand is an GenericQueue instance we have just created above. Note that the GenericQueue is not a static class rather its a instance class unlike the SSQ. You have also noticed that the ms_when_last_call_made and ms_elapsed_since_last_call are pretty self-describing. get_random_id is reponsible for preparing new id for the newly enqueued call.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:b4286d51-b175-49f5-8944-59bed7e1fd96" class="wlWriterSmartContent"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; SequentialServiceQueue &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;{&lt;br /&gt;    timer_id: &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;    ms_when_last_call_made: &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;,          &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; milliseconds (readonly)&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    ms_elapsed_since_last_call: &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;,      &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; milliseconds (readonly)&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    running_task: &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;,&lt;br /&gt;    interval: &lt;/span&gt;&lt;span style="color: #000000;"&gt;10&lt;/span&gt;&lt;span style="color: #000000;"&gt;,                       &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; milliseconds&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    queue: &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; GenericQueue(),&lt;br /&gt;&lt;br /&gt;    get_random_id: &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;() {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; min &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; max &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;10&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Date().getTime() &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; (Math.round((max &lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt; min) &lt;/span&gt;&lt;span style="color: #000000;"&gt;*&lt;/span&gt;&lt;span style="color: #000000;"&gt; Math.random() &lt;/span&gt;&lt;span style="color: #000000;"&gt;+&lt;/span&gt;&lt;span style="color: #000000;"&gt; min));&lt;br /&gt;    },&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;From the code below, as soon as any new call is enqueued, we check for if it is allowed to replace if already exists in the queue with the same name. If found any, we just update that, otherwise we create a brand new task and enqueue and start our updater which is the scheduler in our case.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ae7c30d7-43e7-4af0-8770-8f7883c4cc68" class="wlWriterSmartContent"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #000000;"&gt;nq: &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;(name, replaceIfExists, timeout, code) {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; id &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.get_random_id();&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (replaceIfExists) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; isFound &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;false&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.queue.for_each(&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;(index, element) {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (element &lt;/span&gt;&lt;span style="color: #000000;"&gt;!==&lt;/span&gt;&lt;span style="color: #000000;"&gt; undefined &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style="color: #000000;"&gt; element &lt;/span&gt;&lt;span style="color: #000000;"&gt;!==&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt;undefined&lt;/span&gt;&lt;span style="color: #000000;"&gt;'&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style="color: #000000;"&gt; element.name &lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #000000;"&gt; name) {&lt;br /&gt;                    element.id &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; id;&lt;br /&gt;                    element.replaceIfExists &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; replaceIfExists;&lt;br /&gt;                    element.timeout &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; timeout;&lt;br /&gt;                    element.code &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; code;&lt;br /&gt;                    isFound &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;true&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;                }&lt;br /&gt;            });&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Enqueue new task&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #000000;"&gt;!&lt;/span&gt;&lt;span style="color: #000000;"&gt;isFound &lt;/span&gt;&lt;span style="color: #000000;"&gt;||&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;!&lt;/span&gt;&lt;span style="color: #000000;"&gt;replaceIfExists) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.queue.nq(&lt;br /&gt;            {&lt;br /&gt;                id: id,&lt;br /&gt;                name: name,&lt;br /&gt;                replaceIfExists: replaceIfExists,&lt;br /&gt;                timeout: timeout,&lt;br /&gt;                code: code&lt;br /&gt;            });&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; We have got new tasks, start the updater&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.startUpdater();&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; id;&lt;br /&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The following is the core part of the class which is the scheduler. Inside startUpdater, it executes the block of code in every interval we defined before. And inside the looping code, we check for if there is already any running task, if yes we check for the timeout whether it should make a good timeout or not. Otherwise we let it run as it was. However, if there is no running task at this moment, we dequeue a task and start executing the code and set a starting time for that to keep track of how long it is being running.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ca73c16b-189b-4e4e-8005-66e1353c8e9e" class="wlWriterSmartContent"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #000000;"&gt;detachTask: &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;(id) {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.dq(id);&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.running_task &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.ms_when_last_call_made &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.ms_elapsed_since_last_call &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; See if we are done with the queued tasks&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.queue.is_empty())&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.stopUpdater();&lt;br /&gt;},&lt;br /&gt;&lt;br /&gt;startUpdater: &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;() {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;var&lt;/span&gt;&lt;span style="color: #000000;"&gt; _self &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.timer_id &lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;) {&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.timer_id &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; setInterval(&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;() {&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (_self.running_task &lt;/span&gt;&lt;span style="color: #000000;"&gt;==&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;) {&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; We dont have any running task, lets make the first one&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;                    _self.running_task &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; _self.queue.dq();&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (_self.running_task &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;) {&lt;br /&gt;                        _self.ms_when_last_call_made &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Date().getTime();&lt;br /&gt;                        _self.running_task.code();&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;else&lt;/span&gt;&lt;span style="color: #000000;"&gt; {&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; We have a running task already&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;                    _self.ms_elapsed_since_last_call &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Date().getTime() &lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #000000;"&gt; _self.ms_when_last_call_made;&lt;br /&gt;&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Should the current task be skipped?&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;                    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (_self.ms_elapsed_since_last_call &lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; _self.running_task.timeout)&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt; Time's up. leave the task alone. Let other tasks start executing.&lt;/span&gt;&lt;span style="color: #008000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;                        _self.detachTask(_self.running_task.id);&lt;br /&gt;                }&lt;br /&gt;            }, _self.interval);&lt;br /&gt;    }&lt;br /&gt;},&lt;br /&gt;&lt;br /&gt;stopUpdater: &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;function&lt;/span&gt;&lt;span style="color: #000000;"&gt;() {&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.timer_id &lt;/span&gt;&lt;span style="color: #000000;"&gt;!=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;) {&lt;br /&gt;        clearInterval(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.timer_id)&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.timer_id &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;null&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt;.queue &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; GenericQueue();&lt;br /&gt;},&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Keep an eye on my blog for continued development and improvements, and download CallQueue from: &lt;a href="http://code.msdn.microsoft.com/callqueue"&gt;http://code.msdn.microsoft.com/callqueue&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/5430732659644493117-7910187809425490675?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/7910187809425490675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=7910187809425490675' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/7910187809425490675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/7910187809425490675'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/11/callqueue-implementing-sequential-web.html' title='CallQueue: Implementing a Sequential Web Service Call Queue for AJAX application'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-5236120880348680440</id><published>2008-11-17T20:09:00.001-08:00</published><updated>2008-11-17T20:09:49.042-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Look and Feel'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><title type='text'>My eye friendly Visual Studio dark theme</title><content type='html'>&lt;p&gt;I am not sure about how you guys feel about your IDE look &amp;amp; feel. First few years it was alright for me. However the more I used Visual Studio, the more I experienced problem with my eyes as well as monotony of the same old white background IDE. So, I made a dark theme of Visual Studio which stopped hurting my eyes again. I also tried to keep the syntax yet readable and make careful selection of colors so that important IDE benefits of syntax highlighting was not overlooked. I also tried to avoid absolutely black background, because that demands your eyes to have extra attention to the text since they were prepared to see nothing. So I choose deep navy blue so that it does not hurt your eyes as well as gives your eyes an impression that there may be few things on the screen to read. You may not find it friendly to your eyes, because I am kind of biased to Blue, since its my favorite. &lt;a target="_blank" href="http://tanzimsaqib.com/wp-content/uploads/2008/11/TanzimSaqib-DarkTheme.zip"&gt;You can download the theme from here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;C# View:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_WG4VusHOW0E/SSI__zXCQjI/AAAAAAAAAF0/2v9P5Uc1G9Q/s1600-h/CSharp%5B10%5D.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="CSharp" src="http://lh4.ggpht.com/_WG4VusHOW0E/SSJAAkXrdRI/AAAAAAAAAF4/w7L9ABZTZds/CSharp_thumb%5B6%5D.png?imgmax=800" width="674" height="373" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;HTML View:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_WG4VusHOW0E/SSJABUDKBDI/AAAAAAAAAF8/laFHTjGDXa4/s1600-h/HTML%5B9%5D.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="HTML" src="http://lh3.ggpht.com/_WG4VusHOW0E/SSJACam7-9I/AAAAAAAAAGA/oiRxIMQ2H8E/HTML_thumb%5B5%5D.png?imgmax=800" width="675" height="390" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;XML View:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_WG4VusHOW0E/SSJACpvDAZI/AAAAAAAAAGE/Wd7I4WKH8WU/s1600-h/XML%5B11%5D.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="XML" src="http://lh6.ggpht.com/_WG4VusHOW0E/SSJADKK_qHI/AAAAAAAAAGI/th_fefElEE8/XML_thumb%5B7%5D.png?imgmax=800" width="608" height="259" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Good thing about this theme is it only overrides your Text editor's Font and Color, all other settings of your Visual Studio will remain same. Before you apply this theme to your Visual Studio, you may want to export your current IDE settings, so that you can get back to your old one anytime. To export your current settings and look &amp;amp; feel, use Tools &amp;gt; Import &amp;amp; Export settings. Even if you forget to have a backup, you can reset your IDE settings through that Wizard and will get back Visual Studio factory settings. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-5236120880348680440?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/5236120880348680440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=5236120880348680440' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5236120880348680440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5236120880348680440'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/11/my-eye-friendly-visual-studio-dark.html' title='My eye friendly Visual Studio dark theme'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_WG4VusHOW0E/SSJAAkXrdRI/AAAAAAAAAF4/w7L9ABZTZds/s72-c/CSharp_thumb%5B6%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-225780614463047390</id><published>2008-11-14T03:12:00.001-08:00</published><updated>2008-11-14T03:12:27.400-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Azure'/><title type='text'>Building applications for Windows Azure</title><content type='html'>&lt;p&gt;Windows Azure is an upcoming operating system for the cloud from Microsoft, announced on October 27 at PDC. Windows Azure provides developers with on-demand compute and storage to host, scale, and manage Web applications on the Internet through Microsoft data centers. Azure goes beyond what other providers, such as Rackspace's Mosso or Amazon's EC2, offer. First, it will be available with a complete suite of tools and technologies for building your next big cloud application. Second, the Azure platform's goal is to support all developers and their choice of IDE, language, and technology; meaning that you can use your favorite tools for all kinds of development as well as Python, PHP, Ruby, Eclipse and so on. It supports popular standards and protocols including SOAP, REST, and XML. Using the Windows Azure tools, developers can build, debug, and deploy to Windows Azure directly from their existing development environment.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_WG4VusHOW0E/SR1dF-yBFzI/AAAAAAAAAFc/_uVcb1YVSyw/s1600-h/AzureTodolist10.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="402" alt="AzureTodolist" src="http://lh3.ggpht.com/_WG4VusHOW0E/SR1dGni7yfI/AAAAAAAAAFg/om5HnXev7gs/AzureTodolist_thumb6.png?imgmax=800" width="600" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I have written an article &amp;quot;&lt;a href="http://dotnetslackers.com/articles/aspnet/Building-applications-for-Windows-Azure.aspx" target="_blank"&gt;Building applications for Windows Azure&lt;/a&gt;&amp;quot; which will walk you through the steps to build an application from scratch on the recently released Windows Azure CTP, Microsoft&amp;#8217;s answer to cloud computing. This application will let users add tasks into their Todolists and track them at a later time. The objective of this application is not to use any local data storage like SQL database. Instead, it will store and retrieve data from the cloud which means no matter which language/platform you write your application on, it will be able to access the data. For instance, if you would like to develop an iPhone application which will be able to play with your saved tasks on the go, you will be able to do so. Hope you will enjoy the article.&lt;/p&gt;  &lt;p&gt;Link: &lt;a href="http://dotnetslackers.com/articles/aspnet/Building-applications-for-Windows-Azure.aspx"&gt;http://dotnetslackers.com/articles/aspnet/Building-applications-for-Windows-Azure.aspx&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/5430732659644493117-225780614463047390?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/225780614463047390/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=225780614463047390' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/225780614463047390'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/225780614463047390'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/11/building-applications-for-windows-azure.html' title='Building applications for Windows Azure'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_WG4VusHOW0E/SR1dGni7yfI/AAAAAAAAAFg/om5HnXev7gs/s72-c/AzureTodolist_thumb6.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-9108937665077556009</id><published>2008-11-14T03:10:00.001-08:00</published><updated>2008-11-14T20:16:06.516-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Architecture'/><category scheme='http://www.blogger.com/atom/ns#' term='Azure'/><title type='text'>Client Perspective of Windows Azure Services Platform</title><content type='html'>&lt;p&gt;Windows Azure was announced on PDC 2008 (Oct 27) and will hopefully be released mid next year. You probably already know about Azure by this time. If no, I would like to quote some from &lt;a target="_blank" href="http://www.azure.com"&gt;www.azure.com&lt;/a&gt; as intro: The Azure Services Platform is an internet-scale cloud computing and services platform hosted in Microsoft data centers. The Azure Services Platform provides a range of functionality to build applications that span from consumer web to enterprise scenarios and includes a cloud operating system and a set of developer services. Fully interoperable through the support of industry standards and web protocols such as REST and SOAP, you can use the Azure services individually or together, either to build new applications or to extend existing ones.&lt;/p&gt;  &lt;p&gt;Let us have a quick overview of the clients we usually use in our daily life, then we will explore the potential of Azure and what is waiting for us down to the road:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Windows Client&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Full capabilities, power, rich UI, high performance &lt;/li&gt;    &lt;li&gt;Ability to utilize local resources e.g. audio, camera. &lt;/li&gt;    &lt;li&gt;Capable of blending different hardware and software resulting in amazing applications &lt;/li&gt;    &lt;li&gt;Private data, reliable and fastest &lt;/li&gt;    &lt;li&gt;Personal, trusted and full control &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Web Client&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Data accessibility, availability &lt;/li&gt;    &lt;li&gt;Connect with devices, data services, friends &lt;/li&gt;    &lt;li&gt;Sociability, ability to share &lt;/li&gt;    &lt;li&gt;Interaction, collaboration, email, instant messaging &lt;/li&gt;    &lt;li&gt;Searchable &lt;/li&gt;    &lt;li&gt;Data security is questionable &lt;/li&gt;    &lt;li&gt;Open formats and standards for data exchange &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Mobile Client&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Low capability compared to regular PC horsepower &lt;/li&gt;    &lt;li&gt;Portable: palm reach &lt;/li&gt;    &lt;li&gt;Smart device while powered by web. e.g. Search for restaurants nearby &lt;/li&gt;    &lt;li&gt;Your 24/7 companion &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Smart Client&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Did we forget about Smart Clients? These applications are usually Windows Forms application which take all the advantages of Windows Client including offline storage, utilization of local resources as well as the goodness of internet connectivity. The Smart Client was coined few years ago, but for .NET developers all Windows Client is pretty much generally considered as Smart Clients. The idea behind Smart Client was to utilize full local computing capabilities and exploit the web's accessibility, availability and nature of openness through XML Web Services to developers build great software.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Mesh&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;An important part of Live Services is Mesh, which enables developers to build application for consumer devices which are physically close to them. If you are at home you would be able to access through Windows Client, if you are on the go, you would be through Mobile Client, if you have Internet access only, you would be able to avail the service through Internet. Mesh allows us to get all those devices get connected, exchange data and stay synchronized. You can even add a Mac as device into Mesh to work with. Data communication among devices through Mesh is secured, since the data transferred between them are surely encrypted.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_WG4VusHOW0E/SR1cp87WRgI/AAAAAAAAAE8/bLKdV4KRLHg/s1600-h/image15.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://lh6.ggpht.com/_WG4VusHOW0E/SR1cqGmsrMI/AAAAAAAAAFA/AijaUsoPVlg/image_thumb9.png?imgmax=800" width="459" height="270" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The following screenshots show how you can sync your local PC using Mesh and how your friends can share files or work on files you gave access them to:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_WG4VusHOW0E/SR1cqvaadeI/AAAAAAAAAFE/4u5fRZ-k7gA/s1600-h/demo-howto-share-newpost%5B4%5D.jpg"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="demo-howto-share-newpost" src="http://lh5.ggpht.com/_WG4VusHOW0E/SR1crKx__MI/AAAAAAAAAFI/CRMVdDdeJPU/demo-howto-share-newpost_thumb%5B2%5D.jpg?imgmax=800" width="343" height="334" /&gt;&lt;/a&gt; &lt;a href="http://lh3.ggpht.com/_WG4VusHOW0E/SR1crgIfH6I/AAAAAAAAAFM/1Ju-5QZAS2I/s1600-h/demo-howto-sync-addfolder%5B4%5D.jpg"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="demo-howto-sync-addfolder" src="http://lh3.ggpht.com/_WG4VusHOW0E/SR1csHu5wOI/AAAAAAAAAFQ/U6hPq--YMXo/demo-howto-sync-addfolder_thumb%5B2%5D.jpg?imgmax=800" width="373" height="333" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Goodness of all Clients&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Windows Azure Services Platform is actually an array of technologies, consists of set of tools, and extremely scalable on demand powered by Microsoft datacenters and their ingenious virtualization technology. The core of this platform is to provide user with best experience taking the goodies of each client platform we use in our daily life. Combining the power of HTTP, XML, REST and WebServices Azure lets developers to build cloud enabled applications. The basic advantage of using open and standard protocol for communicating between clients is decreased dependency on the tools, languages or platform of the client. Client could be made by Ruby, Python or it could be in iPhone. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_WG4VusHOW0E/SR5NA0XCMpI/AAAAAAAAAFs/SCeHp_8a_-8/s1600-h/image%5B5%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://lh4.ggpht.com/_WG4VusHOW0E/SR5NBSwYNOI/AAAAAAAAAFw/23dHkUJ7l-M/image_thumb%5B2%5D.png?imgmax=800" width="472" height="466" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Azure enables you to store your data in the cloud. No matter which client you used to work on your data, if you change your client, time-space, you will be able to get back to the same data once you worked on some other devices/OS.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Why hosting cloud application with Microsoft?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Microsoft has 460 millions Live users to date backed up by hundreds of thousands of servers in their datacenters. How many times have you seen Microsoft's sites down? I have not seen many times in life. So, their ability to host, manage super scalable and high traffic websites is not questionable at all. Who else can be a better host of your next big application other than Microsoft?&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-9108937665077556009?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/9108937665077556009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=9108937665077556009' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9108937665077556009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9108937665077556009'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/11/client-perspective-of-windows-azure.html' title='Client Perspective of Windows Azure Services Platform'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_WG4VusHOW0E/SR1cqGmsrMI/AAAAAAAAAFA/AijaUsoPVlg/s72-c/image_thumb9.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-3741648390462138892</id><published>2008-11-13T21:07:00.001-08:00</published><updated>2008-11-13T21:07:02.831-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Azure'/><title type='text'>Cloudship: Membership Provider for the Cloud</title><content type='html'>&lt;p&gt;Planning to move to the Azure Cloud, but already tied to the Membership API? I have recently written an article on Windows Azure which guides you to build a complete Membership provider library which can be leveraged by existing application to link to Microsoft&amp;#8217;s cloud platform Windows Azure with no friction. Goals of this project were to be able to use regular ASP.NET Login controls, existing Membership code e.g. Membersip.UpadateUser(), MembershipUser.ChangePassword().&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_WG4VusHOW0E/SR0HcL0DUOI/AAAAAAAAAE0/teLIKBrat1E/s1600-h/azure_inheritance%5B5%5D.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="65" alt="azure_inheritance" src="http://lh6.ggpht.com/_WG4VusHOW0E/SR0HdY0rojI/AAAAAAAAAE4/W6Atmi2s2Ts/azure_inheritance_thumb%5B3%5D.png?imgmax=800" width="446" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Last, but not least one of the major goals was ease of use. No matter which suite of controls you use: ASP.NET AJAX or MVC, Cloudship can be leveraged as your Membership provider. To install it, into your existing application, simply: &lt;/p&gt;  &lt;p&gt;1. Reference the DLL    &lt;br /&gt;2. Insert few lines inside web.config     &lt;br /&gt;3. You are good to go &lt;/p&gt;  &lt;p&gt;In this article you will learn how to implement your own Membership API, thus you can start moving you application data to the Azure Cloud &amp;#8211; the future of development and business with Microsoft. Here you go - &lt;a href="http://dotnetslackers.com/articles/aspnet/Azure-Cloudship-Membership-Provider-for-the-Cloud.aspx" target="_blank"&gt;Cloudship: Membership Provider for the Cloud&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/5430732659644493117-3741648390462138892?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/3741648390462138892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=3741648390462138892' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3741648390462138892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3741648390462138892'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/11/cloudship-membership-provider-for-cloud.html' title='Cloudship: Membership Provider for the Cloud'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_WG4VusHOW0E/SR0HdY0rojI/AAAAAAAAAE4/W6Atmi2s2Ts/s72-c/azure_inheritance_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-9057009034448914184</id><published>2008-11-01T02:00:00.000-07:00</published><updated>2008-11-04T01:12:17.188-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Azure'/><title type='text'>Fixing DevelopmentStorage's database cannot be found problem on Windows Azure</title><content type='html'>&lt;p&gt;This could be a common problem who are not using SQL Express. If you run an Azure application you may find it seeks for SQL Express instance in your machine if you do not have already. You may also find &amp;quot;An error occurred while processing this request.&amp;quot; error due to this reason while you try creating tables from your models by StorageClient.TableStorage.CreateTablesFromModel. All you need to do is fire up Visual Studio and open the config file for DevelopmentStorage at C:\Program Files\Windows Azure SDK\v1.0\bin\DevelopmentStorage.exe.config. Now modify the connection string and the &lt;em&gt;dbServer&lt;/em&gt; attribute of the service tag for Table, and save.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:743cfbb2-9483-4a59-ace5-c8aa678b4d2f" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: none;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;add &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;DevelopmentStorageDbConnectionString&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;&lt;br /&gt;         connectionString&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;Data Source=.\SQLEXPRESS;Initial Catalog=DevelopmentStorageDb;Integrated Security=True&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;&lt;br /&gt;         providerName&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;System.Data.SqlClient&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;appSettings&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;    &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;add &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;key&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;ClientSettingsProvider.ServiceUri&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; value&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;appSettings&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;developmentStorageConfig&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;services&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;service &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;Blob&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;&lt;br /&gt;               url&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;http://127.0.0.1:10000/&amp;quot;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;service &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;Queue&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;&lt;br /&gt;               url&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;http://127.0.0.1:10001/&amp;quot;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;service &lt;/span&gt;&lt;span style="color: #FF0000;"&gt;name&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;Table&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;&lt;br /&gt;               url&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;http://127.0.0.1:10002/&amp;quot;&lt;/span&gt;&lt;span style="color: #FF0000;"&gt;&lt;br /&gt;               dbServer&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;=&amp;quot;localhost\SQLExpress&amp;quot;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000;"&gt;services&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;br /&gt;    ...&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Restart Visual Studio and open up the Azure project again, now you should be able to run the DevelopmentStorage with the existing database installation of your PC.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-9057009034448914184?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/9057009034448914184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=9057009034448914184' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9057009034448914184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9057009034448914184'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/11/fixing-developmentstorage-database.html' title='Fixing DevelopmentStorage&amp;#39;s database cannot be found problem on Windows Azure'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-9061769631712549726</id><published>2008-10-27T20:33:00.001-07:00</published><updated>2008-10-27T20:33:57.567-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='jQuery'/><title type='text'>jQuery intellisense in Visual Studio</title><content type='html'>&lt;p&gt;Those who are excited like me about the news of jQuery integration into Visual Studio, started adopting jQuery replacing ASP.NET AJAX Client side API. Microsoft also declared there will be a patch for Visual Studio which will support jQuery as well as intellisene for that. For the enthusiasts who just can't for it, here is the way how we can start developing using jQuery with full intellisense support inside Visual Studio 2008:&lt;/p&gt;  &lt;p&gt;1. Download &lt;a title="jquery-1.2.6-vsdoc.js" href="http://jqueryjs.googlecode.com/files/jquery-1.2.6-vsdoc.js"&gt;jquery-1.2.6-vsdoc.js&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;2. Inside your JavaScript files, add a reference to it by placing the following line at the top of the JavaScript file:&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:75bfd113-eb5b-4d43-924d-27184b451c01" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--&lt;br /&gt;&lt;br /&gt;Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt;http://www.CodeHighlighter.com/&lt;br /&gt;&lt;br /&gt;--&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;/ &amp;lt;reference path=&amp;quot;jquery-1.2.6-vsdoc.js&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;That's it. Enjoy!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-9061769631712549726?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/9061769631712549726/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=9061769631712549726' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9061769631712549726'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9061769631712549726'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/10/jquery-intellisense-in-visual-studio_27.html' title='jQuery intellisense in Visual Studio'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-8492109885898570213</id><published>2008-03-28T10:02:00.000-07:00</published><updated>2008-03-31T10:36:05.832-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Simple Form Validation - A Reflection based approach</title><content type='html'>&lt;p&gt;Are you tired of placing multiple Validation controls on Form? If you are bored of following scenario like me, keep on reading the post:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.google.com/saqib1984/R_Eg65B09qI/AAAAAAAAADY/eoWvGFKPozY/Validators%5B5%5D.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="82" alt="Validators" src="http://lh3.google.com/saqib1984/R_Eg_ZB09rI/AAAAAAAAADg/R-hhZWn6K_k/Validators_thumb%5B3%5D.png" width="365" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;A simple Email address validation can consist of whether&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The field is empty  &lt;li&gt;Longer than limit  &lt;li&gt;Email address format is invalid  &lt;li&gt;Already in use&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Ordinary solution to this problem is placing multiple validation controls for a single TextBox. You can simply it by replacing all with a single Custom Validator. Our goal is to reduce amount of controls on the form to keep it simple. To do that, we would have to write code for Custom Validator that does it all. We also would like to write minimum code to validate the control without compromising manageability. Let us assume we would write the following code inside the ServerValidate of that control:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;protected void &lt;/span&gt;cvEmailAddress_ServerValidate(&lt;span style="color: blue"&gt;object &lt;/span&gt;source, &lt;span style="color: #2b91af"&gt;ServerValidateEventArgs &lt;/span&gt;args)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #2b91af"&gt;ValidationController&lt;/span&gt;.ValidateControl&amp;lt;&lt;span style="color: #2b91af"&gt;ProfileValidator&lt;/span&gt;&amp;gt;(cvEmailAddress, &lt;span style="color: #2b91af"&gt;ProfileValidator&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;Fields&lt;/span&gt;.EmailAddress.ToString(), args);&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Let us declare a ValidationErrorResult object that contains error messages and text to display in the UI:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public sealed class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ValidationErrorResult&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;ErrorMessage { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;Text { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;And an Attribute which would be used to tag a specific method which would be responsible for validation of particular control:&lt;/p&gt;&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;AttributeUsage&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;AttributeTargets&lt;/span&gt;.Method, Inherited = &lt;span style="color: blue"&gt;false&lt;/span&gt;, AllowMultiple = &lt;span style="color: blue"&gt;true&lt;/span&gt;)]&lt;br /&gt;&lt;span style="color: blue"&gt;public sealed class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ValidationMethodAttribute &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;Attribute&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;ValidationMethodAttribute(&lt;span style="color: blue"&gt;string &lt;/span&gt;fieldName)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.FieldName = fieldName;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;FieldName { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;private set&lt;/span&gt;; }&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;If you are already familiar with Attirbute based programming, I hope you know the attribute of this piece of code is in fact &lt;span style="color: #2b91af"&gt;ValidationMethod&lt;/span&gt;. We will soon see how to use this. The following is the method that checks the value and make a list of &lt;span style="color: #2b91af"&gt;ValidationErrorResult &lt;/span&gt;that consists of which rules got failed. Notice that the &lt;span style="color: #2b91af"&gt;ValidationMethod&lt;/span&gt; attribute contains the field name of the object which determines no matter whatever your method name is, that field name helps Validation controller to find this method out for validation.&lt;/p&gt;&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;ValidationMethod&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"Email"&lt;/span&gt;)]&lt;br /&gt;&lt;span style="color: blue"&gt;public static &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ValidationErrorResult&lt;/span&gt;&amp;gt; ValidateEmail(&lt;span style="color: blue"&gt;object &lt;/span&gt;value)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;var &lt;/span&gt;email = value &lt;span style="color: blue"&gt;as string&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: blue"&gt;var &lt;/span&gt;results = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ValidationErrorResult&lt;/span&gt;&amp;gt;();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: green"&gt;// Blank&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;.IsNullOrEmpty(email))&lt;br /&gt;        results.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ValidationErrorResult&lt;/span&gt;()&lt;br /&gt;        {&lt;br /&gt;            ErrorMessage = &lt;span style="color: #a31515"&gt;"You did not provide an Email Address."&lt;/span&gt;,&lt;br /&gt;            Text = &lt;span style="color: #a31515"&gt;"Cannot be left blank"&lt;br /&gt;        &lt;/span&gt;});&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: green"&gt;// Length 128&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(email.Length &amp;gt; 128)&lt;br /&gt;        results.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ValidationErrorResult&lt;/span&gt;()&lt;br /&gt;        {&lt;br /&gt;            ErrorMessage = &lt;span style="color: #a31515"&gt;"You exceeded length limit."&lt;/span&gt;,&lt;br /&gt;            Text = &lt;span style="color: #a31515"&gt;"Keep it less than 129 characters"&lt;br /&gt;        &lt;/span&gt;});&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: green"&gt;// Valid Email Address&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(!&lt;span style="color: #2b91af"&gt;Regex&lt;/span&gt;.IsMatch(email, &lt;span style="color: #a31515"&gt;"^[\\w\\.\\-]+@[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]{1,})*(\\.[a-zA-Z]{2,3}){1,2}$"&lt;/span&gt;))&lt;br /&gt;        results.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ValidationErrorResult&lt;/span&gt;()&lt;br /&gt;        {&lt;br /&gt;            ErrorMessage = &lt;span style="color: #a31515"&gt;"You provided an invalid Email Address."&lt;/span&gt;,&lt;br /&gt;            Text = &lt;span style="color: #a31515"&gt;"Invalid Email Address"&lt;br /&gt;        &lt;/span&gt;});&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: green"&gt;// Is Already In Use&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(IsAlreadyInUse(email))&lt;br /&gt;        results.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ValidationErrorResult&lt;/span&gt;()&lt;br /&gt;        {&lt;br /&gt;            ErrorMessage = &lt;span style="color: #a31515"&gt;"You provided an invalid Email Address."&lt;/span&gt;,&lt;br /&gt;            Text = &lt;span style="color: #a31515"&gt;"Invalid Email Address"&lt;br /&gt;        &lt;/span&gt;});&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;return &lt;/span&gt;results;&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Here is the ValidationController which goes through the Validation class and looks for the method that has the attribute which validates the control's value.&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ValidationController&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;public static &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ValidationErrorResult&lt;/span&gt;&amp;gt; Validate&amp;lt;T&amp;gt;(&lt;span style="color: blue"&gt;string &lt;/span&gt;fieldName, &lt;span style="color: blue"&gt;object &lt;/span&gt;value)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;var &lt;/span&gt;results = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ValidationErrorResult&lt;/span&gt;&amp;gt;();&lt;br /&gt;        &lt;span style="color: blue"&gt;var &lt;/span&gt;type = &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(T);&lt;br /&gt;        &lt;span style="color: blue"&gt;var &lt;/span&gt;methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;var &lt;/span&gt;method = methods.Single&amp;lt;MethodInfo&amp;gt;(&lt;span style="color: blue"&gt;delegate&lt;/span&gt;(MethodInfo m)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;((&lt;span style="color: #2b91af"&gt;ValidationMethodAttribute&lt;/span&gt;[])m.GetCustomAttributes(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;ValidationMethodAttribute&lt;/span&gt;), &lt;span style="color: blue"&gt;false&lt;/span&gt;))[0].FieldName == fieldName;&lt;br /&gt;        });&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ValidationErrorResult&lt;/span&gt;&amp;gt;)method.Invoke(&lt;span style="color: blue"&gt;null&lt;/span&gt;, &lt;span style="color: blue"&gt;new object&lt;/span&gt;[] { value });&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public static void &lt;/span&gt;ValidateControl&amp;lt;T&amp;gt;(&lt;span style="color: #2b91af"&gt;CustomValidator &lt;/span&gt;validator, &lt;span style="color: blue"&gt;string &lt;/span&gt;fieldName, &lt;span style="color: #2b91af"&gt;ServerValidateEventArgs &lt;/span&gt;args)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;var &lt;/span&gt;results = Validate&amp;lt;T&amp;gt;(fieldName, args.Value);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(!(args.IsValid = !(results.Count &amp;gt; 0)))&lt;br /&gt;        {&lt;br /&gt;            validator.ErrorMessage = results[0].ErrorMessage;&lt;br /&gt;            validator.Text = results[0].Text;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-8492109885898570213?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/8492109885898570213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=8492109885898570213' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/8492109885898570213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/8492109885898570213'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/03/simple-form-validation-reflection-based.html' title='Simple Form Validation - A Reflection based approach'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-7828137498749293472</id><published>2008-03-02T12:03:00.000-08:00</published><updated>2008-03-02T12:35:36.415-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><title type='text'>Use your personal blog with Windows Live Writer</title><content type='html'>&lt;p&gt;I'm very glad to tell you that your ".NET Research" personal blog is compatible with &lt;a href="http://writer.live.com/" target="_blank"&gt;Windows Live Writer&lt;/a&gt;. You can compose, format, insert photos inside your posts offline and publish when you become online totally from this client without even opening the ".NET Research" site. Let us the steps to do this assuming you have properly installed Windows Live Writer.&lt;/p&gt; &lt;p&gt;Step 1. Run Windows Live Writer and Weblog &amp;gt; Add Weblog account..&lt;/p&gt; &lt;p&gt;Step 2. Choose another weblog service like the following screen and click Next:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.google.com/saqib1984/R8sPh_Sup8I/AAAAAAAAAC4/40vhvE5V48I/Step2%5B3%5D"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="270" alt="Step2" src="http://lh6.google.com/saqib1984/R8sPjPSup9I/AAAAAAAAADA/YrCwD1YnXUE/Step2_thumb%5B1%5D" width="310" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Step 3. Now type &lt;a href="http://dotnetbd.org"&gt;http://dotnetbd.org&lt;/a&gt; as your Weblog Homepage URL, enter your credential like here I used as &lt;em&gt;admin&lt;/em&gt;:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.google.com/saqib1984/R8sPkfSup-I/AAAAAAAAADI/s2utxriRe70/Step3%5B5%5D"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="271" alt="Step3" src="http://lh3.google.com/saqib1984/R8sPlfSup_I/AAAAAAAAADQ/M6LQs_yNE5U/Step3_thumb%5B3%5D" width="310" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now Windows Live Writer will download some necessary files to work offline and will appear with a white blank screen for you to write your first post! That's it. These simple two steps will enable you to use this powerful tool to work with your ".NET Research" personal blog. Happy blogging!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-7828137498749293472?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/7828137498749293472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=7828137498749293472' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/7828137498749293472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/7828137498749293472'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/03/use-your-personal-blog-with-windows.html' title='Use your personal blog with Windows Live Writer'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-7005301926789794794</id><published>2008-03-01T08:09:00.001-08:00</published><updated>2008-03-01T08:09:10.478-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>LINQ to Flickr</title><content type='html'>&lt;p&gt;One of my colleagues &lt;a href="http://weblogs.asp.net/mehfuzh"&gt;Mehfuz Hossain&lt;/a&gt; developed a wonderful open source project which allows you to query Flickr photos by LINQ, also lets you insert, delete photos directly to/from Flickr. You wonder how to extend LINQ in such an amazing way? It’s easy by writing your own custom LINQ provider, which was not-so-easy until he came up with another handy open source project named &lt;a href="http://www.codeplex.com/linqextender"&gt;LINQ Extender&lt;/a&gt;&lt;a href="http://www.codeplex.com/linqextender"&gt;&lt;/a&gt;. He did all the expression parsing stuff to ease our pain. Now you can make your own LINQ to Anything using this so easily.&lt;/p&gt; &lt;p&gt;For your heads up on LINQ extenders, here &lt;a href="http://dotnetslackers.com/articles/csharp/CreatingCustomLINQProviderUsingLinqExtender.aspx"&gt;he wrote an article&lt;/a&gt; and &lt;a href="http://www.codeplex.com/LINQFlickr"&gt;LINQ to Flickr&lt;/a&gt;, open source project is hosted at Codeplex.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-7005301926789794794?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/7005301926789794794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=7005301926789794794' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/7005301926789794794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/7005301926789794794'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/03/linq-to-flickr.html' title='LINQ to Flickr'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-774688797278183842</id><published>2008-02-05T23:43:00.001-08:00</published><updated>2008-02-05T23:43:31.213-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>A "transactional" generic DbHelper for LINQ to SQL</title><content type='html'>&lt;p&gt;In LINQ to SQL, the data model of a relational database is mapped to an object model expressed in the programming language of the developer. When the application runs, LINQ to SQL translates into SQL the language-integrated queries in the object model and sends them to the database for execution. When the database returns the results, LINQ to SQL translates them back to objects that you can work with in your own programming language. You may want to make a data access layer that separates the data operation from business layer like the following:&lt;/p&gt;  &lt;pre class="code"&gt;DbHelper.Insert&amp;lt;&lt;font color="#2b91af"&gt;Student&lt;/font&gt;&amp;gt;(&lt;br /&gt;    new &lt;font color="#2b91af"&gt;Student&lt;/font&gt;()&lt;br /&gt;    {&lt;br /&gt;        FirstName = &lt;span style="color: #a31515"&gt;&amp;quot;Tanzim&amp;quot;&lt;/span&gt;,&lt;br /&gt;        LastName = &lt;span style="color: #a31515"&gt;&amp;quot;Saqib&amp;quot;&lt;/span&gt;,&lt;br /&gt;        Email = &lt;span style="color: #a31515"&gt;&amp;quot;me@TanzimSaqib.com&amp;quot;&lt;/span&gt;,&lt;br /&gt;        Website = &lt;span style="color: #a31515"&gt;&amp;quot;http://www.TanzimSaqib.com&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;}, &lt;span style="color: blue"&gt;true&lt;/span&gt;);    &lt;span style="color: green"&gt;// Use Transaction?&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To make use of such transactional generic DbHelper, you might want to write a singeton DbHelper class like the following. You might notice that the class is singleton, it's static and the DataContext is being used is private, and only initialized using the connection string if not yet.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DbHelper&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;private const string &lt;/span&gt;CONNECTION_CONFIG_NAME = &lt;span style="color: #a31515"&gt;&amp;quot;StudentServerConnectionString&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;private static &lt;/span&gt;StudentServerDataContext _StudentServerDataContext = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public static &lt;/span&gt;StudentServerDataContext GetDataContext()&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;if&lt;/span&gt;(_StudentServerDataContext == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;            _StudentServerDataContext = &lt;span style="color: blue"&gt;new &lt;/span&gt;StudentServerDataContext&lt;br /&gt;                (&lt;span style="color: #2b91af"&gt;ConfigurationManager&lt;/span&gt;.ConnectionStrings&lt;br /&gt;                [CONNECTION_CONFIG_NAME].ConnectionString);&lt;br /&gt;        &lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;_StudentServerDataContext;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public static void &lt;/span&gt;CleanUp()&lt;br /&gt;    {&lt;br /&gt;        _StudentServerDataContext.Dispose();&lt;br /&gt;        _StudentServerDataContext = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: green"&gt;// ... code edited to save space&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;On application wide error or on end you can dispose the context so CleanUp method is useful here. To implement an Insert method see the following. You will find I have used a TransactionScope which ensures that the transaction is taking place without any interruption. If there is really any error the scope.Complete() method never gets invoked. This is how it ensures that the code inside the TransactionScope is taking place as a transaction. It is available from .NET 2.0 framework.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static void &lt;/span&gt;Insert&amp;lt;T&amp;gt;(T t, &lt;span style="color: blue"&gt;bool &lt;/span&gt;isTransactional) &lt;span style="color: blue"&gt;where &lt;/span&gt;T : &lt;span style="color: blue"&gt;class&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;if &lt;/span&gt;(isTransactional)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;using &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;scope = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TransactionScope&lt;/span&gt;())&lt;br /&gt;        {&lt;br /&gt;            Insert&amp;lt;T&amp;gt;(t);&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: green"&gt;// On any Exception, Complete() method won't be invoked.&lt;br /&gt;            // So, the transaction will be automatically rollbacked.&lt;br /&gt;            &lt;/span&gt;scope.Complete();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: blue"&gt;else&lt;br /&gt;        &lt;/span&gt;Insert&amp;lt;T&amp;gt;(t);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;public static void &lt;/span&gt;Insert&amp;lt;T&amp;gt;(T t) &lt;span style="color: blue"&gt;where &lt;/span&gt;T : &lt;span style="color: blue"&gt;class&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;using &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;db = GetDataContext())&lt;br /&gt;    {&lt;br /&gt;        db.GetTable&amp;lt;T&amp;gt;().InsertOnSubmit(t);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;try&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;            db.SubmitChanges();&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;e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: green"&gt;// TODO: log Exception&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: blue"&gt;throw &lt;/span&gt;e;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;I did not show other methods as part of the CRUD implementation. The rest is left open for you to implement.  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-774688797278183842?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/774688797278183842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=774688797278183842' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/774688797278183842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/774688797278183842'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/02/generic-dbhelper-for-linq-to-sql.html' title='A &amp;quot;transactional&amp;quot; generic DbHelper for LINQ to SQL'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-2326211600101865383</id><published>2008-02-04T21:37:00.001-08:00</published><updated>2008-02-04T21:37:53.939-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Workflow'/><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>[New Article] 7 ways to do Performance Optimization of an ASP.NET 3.5 Web 2.0 portal</title><content type='html'>&lt;p&gt;Web 2.0 applications are widely developed. These applications often work with third party contents, aggregate them, make various use of them and then make something useful and meaningful to the users. For the past few years, developers were also engaged with such endeavors and a lot of their websites have not addressed performance issues, thus resulting in an unpleasant experience to the users.&lt;/p&gt;  &lt;p&gt;Performance is a vast area and great results can never be achieved by a silver bullet. &lt;a href="http://dotnetslackers.com/articles/aspnet/SevenWaysToDoPerformanceOptimizationOfAnASPNET35Web20Portal.aspx" target="_blank"&gt;This article&lt;/a&gt; explores some of the key performance issues that can occur while developing a Web 2.0 portal using server side multithreading and caching. It also demonstrates model driven application development using Windows Workflow Foundation. &lt;/p&gt;  &lt;p&gt;URL: &lt;a title="http://dotnetslackers.com/articles/aspnet/SevenWaysToDoPerformanceOptimizationOfAnASPNET35Web20Portal.aspx" href="http://dotnetslackers.com/articles/aspnet/SevenWaysToDoPerformanceOptimizationOfAnASPNET35Web20Portal.aspx"&gt;http://dotnetslackers.com/articles/aspnet/SevenWaysToDoPerformanceOptimizationOfAnASPNET35Web20Portal.aspx&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/5430732659644493117-2326211600101865383?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/2326211600101865383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=2326211600101865383' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/2326211600101865383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/2326211600101865383'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/02/new-article-7-ways-to-do-performance.html' title='[New Article] 7 ways to do Performance Optimization of an ASP.NET 3.5 Web 2.0 portal'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-6157816561944556473</id><published>2008-01-29T12:25:00.001-08:00</published><updated>2008-01-29T12:25:46.187-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Volta'/><title type='text'>Write your own DOM friendly extension methods for HtmlElement in Volta</title><content type='html'>&lt;p&gt;&lt;a href="http://lh3.google.com/saqib1984/R5-LxFnTnxI/AAAAAAAAACo/sf3hO-Xi2hw/logo-volta%5B7%5D"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="75" alt="logo-volta" src="http://lh6.google.com/saqib1984/R5-Lx1nTnyI/AAAAAAAAACw/4wz1lnlOdpc/logo-volta_thumb%5B5%5D" width="189" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I know there are &lt;strong&gt;GetById&lt;/strong&gt;, &lt;strong&gt;GetById&amp;lt;&amp;gt;&lt;/strong&gt; methods in Document object. But, I often miss a method that I feel should be in Volta, which iterates through its child nodes and find an element for me. Let us say, there is a HTML like the following:&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;div &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;divContainer&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;b&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;Some text&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;b&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;div &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;firstDiv&amp;quot;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;i&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;Some more text&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;i&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;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;div &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;secondDiv&amp;quot;&amp;gt;&lt;br /&gt;        &lt;/span&gt;Okay, I gotta go now&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;div &lt;/span&gt;&lt;span style="color: red"&gt;anyAttribute&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;anyValue&amp;quot;&amp;gt;&lt;br /&gt;        &lt;/span&gt;Babye&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;div&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;The most important thing is, I can not get the last div by Document.&lt;strong&gt;GetById&lt;/strong&gt;, because instead of id I chose &lt;strong&gt;anyAttribute&lt;/strong&gt;. So, I wrote my own extension method which can run into not only Div but also any &lt;strong&gt;HtmlElement&lt;/strong&gt;, and can find me the desired &lt;strong&gt;HtmlElement&lt;/strong&gt; inside the prior one with the &lt;strong&gt;anyAttribute&lt;/strong&gt; and &lt;strong&gt;anyValue&lt;/strong&gt;. To make my intention clear, I'd like to show how I'd like to use that extension method: &lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;divContainer = Document.GetById&amp;lt;&lt;span style="color: #2b91af"&gt;Div&lt;/span&gt;&amp;gt;(&lt;span style="color: #a31515"&gt;&amp;quot;divContainer&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;anyDiv = divContainer.Find&amp;lt;&lt;span style="color: #2b91af"&gt;Div&lt;/span&gt;&amp;gt;(&lt;span style="color: #a31515"&gt;&amp;quot;anyAttribute&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;anyValue&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt;(anyDiv != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;    anyDiv.InnerHtml += &lt;span style="color: #a31515"&gt;&amp;quot;guys!&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;So, I'd like to call my extension method &lt;strong&gt;Find&amp;lt;&amp;gt;&lt;/strong&gt; which will take the type I'm looking for (in this case a Div) and that &lt;strong&gt;HtmlElement&lt;/strong&gt; should have an attribute &amp;quot;&lt;strong&gt;anyAttribute&lt;/strong&gt;&amp;quot; that contains &amp;quot;&lt;strong&gt;anyValue&lt;/strong&gt;&amp;quot;. Here is how I make up the extension method: &lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;HtmlExtensions&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;public static &lt;/span&gt;T Find&amp;lt;T&amp;gt;(&lt;span style="color: blue"&gt;this &lt;/span&gt;T parent, &lt;span style="color: blue"&gt;string &lt;/span&gt;attribute, &lt;span style="color: blue"&gt;string &lt;/span&gt;value)&lt;br /&gt;        &lt;span style="color: blue"&gt;where &lt;/span&gt;T : &lt;span style="color: #2b91af"&gt;HtmlElement&lt;br /&gt;    &lt;/span&gt;{&lt;br /&gt;        &lt;span style="color: blue"&gt;var &lt;/span&gt;element = parent.FirstChild; &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;while&lt;/span&gt;(element != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(element.IsProper&amp;lt;T&amp;gt;(attribute, value))&lt;br /&gt;                &lt;span style="color: blue"&gt;return &lt;/span&gt;element &lt;span style="color: blue"&gt;as &lt;/span&gt;T;&lt;br /&gt;            &lt;span style="color: blue"&gt;else&lt;br /&gt;                &lt;/span&gt;element = element.NextSibling; &lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return null&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public static bool &lt;/span&gt;IsProper&amp;lt;T&amp;gt;(&lt;span style="color: blue"&gt;this &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DomNode &lt;/span&gt;element, &lt;span style="color: blue"&gt;string &lt;/span&gt;attribute, &lt;span style="color: blue"&gt;string &lt;/span&gt;value)&lt;br /&gt;        &lt;span style="color: blue"&gt;where &lt;/span&gt;T : &lt;span style="color: #2b91af"&gt;HtmlElement&lt;br /&gt;    &lt;/span&gt;{&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(element.GetType() == &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(T) &amp;amp;&amp;amp;&lt;br /&gt;            element.Attributes != &lt;span style="color: blue"&gt;null &lt;/span&gt;&amp;amp;&amp;amp;&lt;br /&gt;            element.Attributes.GetNamedItem(attribute) != &lt;span style="color: blue"&gt;null &lt;/span&gt;&amp;amp;&amp;amp;&lt;br /&gt;            element.Attributes.GetNamedItem(attribute).Value == value)&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;return true&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return false&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;This method can iterate only one depth. Multi depth implementation can be done by running a simple DFS which is left to you guys. Note one thing, I have called one extension method &amp;quot;&lt;strong&gt;IsProper&lt;/strong&gt;&amp;quot; inside another extension method, and there is no harm in it. So, this is how you can add your own extension methods to the &lt;strong&gt;HtmlElement&lt;/strong&gt;.  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-6157816561944556473?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/6157816561944556473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=6157816561944556473' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/6157816561944556473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/6157816561944556473'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/write-your-own-dom-friendly-extension.html' title='Write your own DOM friendly extension methods for HtmlElement in Volta'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-4104893033567699013</id><published>2008-01-26T14:01:00.001-08:00</published><updated>2008-01-26T14:01:57.679-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Volta'/><title type='text'>Appearing on Microsoft Volta team blog</title><content type='html'>&lt;p&gt;Microsoft Volta team blogged about me and one of my articles: &lt;a href="http://labs.live.com/volta/blog/Volta+How+To+Flickr+Widget.aspx" target="_blank"&gt;http://labs.live.com/volta/blog/Volta+How+To+Flickr+Widget.aspx&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.google.com/saqib1984/R5utu1nTnvI/AAAAAAAAACY/Z8e-YggCZ30/VoltaTeamBlog%5B5%5D"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="193" alt="VoltaTeamBlog" src="http://lh6.google.com/saqib1984/R5utw1nTnwI/AAAAAAAAACg/BBWFTcI9DIg/VoltaTeamBlog_thumb%5B3%5D" width="563" 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/5430732659644493117-4104893033567699013?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/4104893033567699013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=4104893033567699013' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/4104893033567699013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/4104893033567699013'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/appearing-on-microsoft-volta-team-blog.html' title='Appearing on Microsoft Volta team blog'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-8443804889270953998</id><published>2008-01-26T11:20:00.001-08:00</published><updated>2008-01-26T11:20:58.947-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>[New Article] ASP.NET AJAX Best Practices</title><content type='html'>&lt;p&gt;While we develop AJAX applications, we often carelessly ignore giving up bad practices, which cause effects which are not so significantly visible when the site is not so large in volume. But, it&amp;#8217;s often severe performance issue when it is the case for sites that make heavy use of AJAX technologies such as Pageflakes, NetVibes etc. &lt;/p&gt;  &lt;p&gt;There are so many AJAX widgets in one page that little memory leak issues combined may even result the site crash into very nasty &amp;#8220;Operation aborted&amp;#8221;. There are a lot of WebService calls, lot of iterations among collection so that inefficient coding in a whole lead to make site very heavy, browser eats up a lot of memory, requires very costly CPU cycles, and ultimately causes unsatisfactory user experience. In this article many of such issues are demonstrated in the context of ASP.NET AJAX.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.codeproject.com/KB/ajax/AspNetAjaxBestPractices.aspx" href="http://www.codeproject.com/KB/ajax/AspNetAjaxBestPractices.aspx" target="_blank"&gt;http://www.codeproject.com/KB/ajax/AspNetAjaxBestPractices.aspx&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/5430732659644493117-8443804889270953998?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/8443804889270953998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=8443804889270953998' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/8443804889270953998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/8443804889270953998'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/new-article-aspnet-ajax-best-practices.html' title='[New Article] ASP.NET AJAX Best Practices'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-9065365834327910786</id><published>2008-01-25T09:16:00.001-08:00</published><updated>2008-01-25T09:16:54.597-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Volta'/><title type='text'>HttpRequestFactory vs. XMLHttpRequest in Volta</title><content type='html'>&lt;p&gt;HttpRequestFactory was designed for use by tiersplitting internally and was not supposed to be exposed as part of the Volta API as Danny van Velzen from Microsoft Volta team told me today. So, its better if you use XMLHttpRequest instead because this factory class might not show up in the later releases. You will find this class in Microsoft.LiveLabs.Volta.Xml namespace.&amp;#160; As like as JavaScript's one, in this .NET version you can also Open URL, specify method name, and of course pass credentials. You can track response text, xml, status code, status text and also you can abort. &lt;/p&gt;  &lt;p&gt;To retrieve your content, you must subscribe to ReadyStateChange event with a HtmlEventHandler which you can find in Microsoft.LiveLabs.Volta.Html namespace and check the status code. If it is 200 that means &amp;quot;HTTP OK&amp;quot;, you can take the ResponseText or ResponseXML. See this example:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;string &lt;/span&gt;content = &lt;span style="color: blue"&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;request = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;XMLHttpRequest&lt;/span&gt;();&lt;br /&gt;&lt;br /&gt;request.ReadyStateChange += &lt;span style="color: blue"&gt;delegate&lt;/span&gt;()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;if &lt;/span&gt;(request.Status == 200)&lt;br /&gt;        content = request1.ResponseText;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;request.Open(&lt;span style="color: #a31515"&gt;&amp;quot;POST&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;http://tanzimsaqib.com/feed/&amp;quot;&lt;/span&gt;, &lt;span style="color: blue"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;br /&gt;However, you cannot fetch cross domain content by XMLHttpRequest. The Volta compiler creates client side JavaScript XMLHttpRequest and lets developers write code in .NET friendly way. So, I do not think there is any way to retrieve cross domain content in Volta, and leaving us on the same old HttpRequest class.  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-9065365834327910786?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/9065365834327910786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=9065365834327910786' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9065365834327910786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9065365834327910786'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/httprequestfactory-vs-xmlhttprequest-in.html' title='HttpRequestFactory vs. XMLHttpRequest in Volta'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-3950449827297670440</id><published>2008-01-18T07:38:00.001-08:00</published><updated>2008-01-18T07:38:30.495-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Volta'/><title type='text'>[New Article] Building a Volta Control : A Flickr Widget</title><content type='html'>&lt;p&gt;This is my first article which is based on the first CTP of Volta considering its current limitations. You will see how you can create a Volta control that the compiler can convert into an AJAX Widget without requiring us writing a single line of JavaScript code: &lt;a title="http://dotnetslackers.com/articles/aspnet/BuildingAVoltaControlAFlickrWidget.aspx" href="http://dotnetslackers.com/articles/aspnet/BuildingAVoltaControlAFlickrWidget.aspx"&gt;http://dotnetslackers.com/articles/aspnet/BuildingAVoltaControlAFlickrWidget.aspx&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/5430732659644493117-3950449827297670440?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/3950449827297670440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=3950449827297670440' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3950449827297670440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3950449827297670440'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/new-article-building-volta-control.html' title='[New Article] Building a Volta Control : A Flickr Widget'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-9203577357051334715</id><published>2008-01-14T11:36:00.001-08:00</published><updated>2008-01-26T11:39:26.411-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>ASP.NET AJAX Best Practices: Avoid String concatenation, use Array instead</title><content type='html'>&lt;p&gt;Don't you think the following block of code has written keeping every possible good practice in mind? Any option for performance improvement?&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;pageLoad()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;var &lt;/span&gt;stringArray = &lt;span style="color: blue"&gt;new &lt;/span&gt;Array();&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: green"&gt;// Suppose there're a lot of strings in the array like:&lt;br /&gt;    &lt;/span&gt;stringArray.push(&lt;span style="color: #a31515"&gt;'&amp;lt;div&amp;gt;'&lt;/span&gt;);&lt;br /&gt;    stringArray.push(&lt;span style="color: #a31515"&gt;'some content'&lt;/span&gt;);&lt;br /&gt;    stringArray.push(&lt;span style="color: #a31515"&gt;'&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: green"&gt;// ... code edited to save space&lt;br /&gt;    &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;veryLongHtml = $get(&lt;span style="color: #a31515"&gt;'divContent'&lt;/span&gt;).innerHTML;&lt;br /&gt;    &lt;span style="color: blue"&gt;var &lt;/span&gt;count = stringArray.length;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;count; ++i)&lt;br /&gt;        veryLongHtml += stringArray[i];    &lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Well, as you see the &lt;code&gt;innerHTML &lt;/code&gt;of the div has been cached so that browser will not have to access the DOM every time while iterating through &lt;code&gt;stringArray&lt;/code&gt;, thus costlier DOM methods are being avoided. But, inside the body of the loop the JavaScript interpreter has to perform the following operation:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;veryLongHtml = veryLongHtml + stringArray[i];&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;And the veryLongHtml contains quite a large string which means in this operation the interpreter will have to retrieve the large string and then concatenate with the stringArray elements in every iteration. One very short yet efficient solution to this problem is using join method of the array like the following, instead of looping through the array:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;veryLongHtml = stringArray.join(&lt;span style="color: #a31515"&gt;''&lt;/span&gt;); &lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;However, this is very efficient than the one we were doing, since it joins the array with smaller strings which requires less memory.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-9203577357051334715?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/9203577357051334715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=9203577357051334715' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9203577357051334715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9203577357051334715'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-avoid-string_14.html' title='ASP.NET AJAX Best Practices: Avoid String concatenation, use Array instead'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-5244482933518264594</id><published>2008-01-14T11:36:00.000-08:00</published><updated>2008-01-26T11:38:29.929-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>ASP.NET AJAX Best Practices: Avoid String concatenation, use Array instead</title><content type='html'>&lt;p&gt;Don't you think the following block of code has written keeping every possible good practice in mind? Any option for performance improvement?&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;pageLoad()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;var &lt;/span&gt;stringArray = &lt;span style="color: blue"&gt;new &lt;/span&gt;Array();&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: green"&gt;// Suppose there're a lot of strings in the array like:&lt;br /&gt;    &lt;/span&gt;stringArray.push(&lt;span style="color: #a31515"&gt;'&amp;lt;div&amp;gt;'&lt;/span&gt;);&lt;br /&gt;    stringArray.push(&lt;span style="color: #a31515"&gt;'some content'&lt;/span&gt;);&lt;br /&gt;    stringArray.push(&lt;span style="color: #a31515"&gt;'&amp;lt;/div&amp;gt;'&lt;/span&gt;);&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: green"&gt;// ... code edited to save space&lt;br /&gt;    &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;veryLongHtml = $get(&lt;span style="color: #a31515"&gt;'divContent'&lt;/span&gt;).innerHTML;&lt;br /&gt;    &lt;span style="color: blue"&gt;var &lt;/span&gt;count = stringArray.length;&lt;br /&gt;    &lt;br /&gt;    &lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;count; ++i)&lt;br /&gt;        veryLongHtml += stringArray[i];    &lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Well, as you see the &lt;code&gt;innerHTML &lt;/code&gt;of the div has been cached so that browser will not have to access the DOM every time while iterating through &lt;code&gt;stringArray&lt;/code&gt;, thus costlier DOM methods are being avoided. But, inside the body of the loop the JavaScript interpreter has to perform the following operation:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;veryLongHtml = veryLongHtml + stringArray[i];&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;And the veryLongHtml contains quite a large string which means in this operation the interpreter will have to retrieve the large string and then concatenate with the stringArray elements in every iteration. One very short yet efficient solution to this problem is using join method of the array like the following, instead of looping through the array:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;veryLongHtml = stringArray.join(&lt;span style="color: #a31515"&gt;''&lt;/span&gt;); &lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;However, this is very efficient than the one we were doing, since it joins the array with smaller strings which requires less memory.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-5244482933518264594?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/5244482933518264594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=5244482933518264594' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5244482933518264594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5244482933518264594'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-avoid-string.html' title='ASP.NET AJAX Best Practices: Avoid String concatenation, use Array instead'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-3490320841285243536</id><published>2008-01-14T10:19:00.000-08:00</published><updated>2008-01-14T10:23:38.741-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><title type='text'>How to solve: Server Controls can't be accessed in View's code-behind in ASP.NET MVC</title><content type='html'>&lt;p&gt;It's still long way to go for a final release of ASP.NET MVC, the one I've been using right now is just a December CTP. But, like me you might be experiencing this confusing problem. The server controls that you put in a View (ViewContentPage) can not be found in code-behind page. The reason behind it is - the Views don't have a back-end designer code file. I believe it's just a bug or they could not find time to fix/look into it. I'm sure it will be fixed in any of the upcoming versions.&lt;/p&gt;  &lt;p&gt;To enable this, switch to Solution Explorer, right click on the View you are interested in, and choose Convert to Web Application. Now, you will find the server controls in code-behind file.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-3490320841285243536?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/3490320841285243536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=3490320841285243536' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3490320841285243536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3490320841285243536'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/how-to-solve-server-controls-can-be.html' title='How to solve: Server Controls can&amp;#39;t be accessed in View&amp;#39;s code-behind in ASP.NET MVC'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-5124991012488737368</id><published>2008-01-12T11:33:00.000-08:00</published><updated>2008-01-26T11:35:43.883-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>ASP.NET AJAX Best Practices: Introduce function delegates</title><content type='html'>&lt;p&gt;Take a look at the following loop. This loop calls a function in each iteration and the function does some stuffs. Can you think of any performance improvement idea?&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;count; ++i)&lt;br /&gt;    processElement(elements[i]);&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Well, for sufficiently large array, function delegates may result in significant performance improvement to the loop.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;delegate = processElement;&lt;br /&gt;    &lt;br /&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;count; ++i)&lt;br /&gt;    delegate(elements[i]);&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The reason behind performance improvement is, JavaScript interpreter will use the function as local variable and will not lookup in its scope chain for the function body in each iteration.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-5124991012488737368?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/5124991012488737368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=5124991012488737368' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5124991012488737368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5124991012488737368'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-introduce_12.html' title='ASP.NET AJAX Best Practices: Introduce function delegates'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-2644991918344005419</id><published>2008-01-11T11:28:00.000-08:00</published><updated>2008-01-26T11:30:38.337-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>ASP.NET AJAX Best Practices: Introduce DOM elements and function caching</title><content type='html'>&lt;p&gt;&lt;/p&gt; We have seen DOM caching before and function delegation is also a kind of function caching. Take a look at the following snippet:  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;count; ++i)&lt;br /&gt;    $get(&lt;span style="color: #a31515"&gt;'divContent'&lt;/span&gt;).appendChild(elements[i]); &lt;/pre&gt;&lt;br /&gt;As you can figure out the code is going to be something like:&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;divContent = $get(&lt;span style="color: #a31515"&gt;'divContent'&lt;/span&gt;);&lt;br /&gt;    &lt;br /&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;count; ++i)&lt;br /&gt;    divContent.appendChild(elements[i]); &lt;/pre&gt;&lt;br /&gt;That is fine, but you can also cache browser function like &lt;code&gt;appendChild&lt;/code&gt;. So, the ultimate optimization will be like the following:&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;divContentAppendChild = $get(&lt;span style="color: #a31515"&gt;'divContent'&lt;/span&gt;).appendChild;&lt;br /&gt;    &lt;br /&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;count; ++i)&lt;br /&gt;    divContentAppendChild(elements[i]);   &lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-2644991918344005419?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/2644991918344005419/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=2644991918344005419' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/2644991918344005419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/2644991918344005419'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-introduce.html' title='ASP.NET AJAX Best Practices: Introduce DOM elements and function caching'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-7911248092947471646</id><published>2008-01-10T11:26:00.000-08:00</published><updated>2008-01-26T11:27:40.599-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>ASP.NET AJAX Best Practices: Problem with switch</title><content type='html'>&lt;p&gt;Unlike .NET languages or any other compiler languages, JavaScript interpreter can not optimize switch block. Especially when switch statement is used with different types of data, it's a heavy operation for the browser due to conversion operations occur in consequences, it's an elegant way of decision branching though.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-7911248092947471646?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/7911248092947471646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=7911248092947471646' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/7911248092947471646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/7911248092947471646'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-problem-with.html' title='ASP.NET AJAX Best Practices: Problem with switch'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-5987281559072647957</id><published>2008-01-09T23:10:00.000-08:00</published><updated>2008-01-25T23:19:36.549-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>ASP.NET AJAX Best Practices: Avoid using Array.length in a loop</title><content type='html'>&lt;p&gt;In one of my earlier posts, I talked about DOM element accessing in a loop but forgot to talk about a very common, yet performance issue in AJAX. We often use code like the following:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;items = []; &lt;span style="color: green"&gt;// Suppose a very long array &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;items.length; ++i)&lt;br /&gt;    ; &lt;span style="color: green"&gt;// Some actions&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;It can be a severe performance issue if the array is so large. JavaScript is an interpreted language, so when interpreter executes code line by line, every time it checks the condition inside the loop, you end up accessing the length property every time. Where it is applicable, if the contents of the array does not need to be changed during the loop's execution, there is no necessity to access the length property every time. Take out the length in a variable and use in every iteration: &lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;items = []; &lt;span style="color: green"&gt;// Suppose a very long array &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;count = items.length;&lt;br /&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;count; ++i)&lt;br /&gt;    ; &lt;span style="color: green"&gt;// Some actions&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/5430732659644493117-5987281559072647957?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/5987281559072647957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=5987281559072647957' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5987281559072647957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5987281559072647957'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-avoid-using.html' title='ASP.NET AJAX Best Practices: Avoid using Array.length in a loop'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-5604288928324002178</id><published>2008-01-08T13:18:00.000-08:00</published><updated>2008-01-09T13:22:57.282-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Volta'/><title type='text'>Make web.config work in Volta</title><content type='html'>&lt;p&gt; &lt;img src="http://labs.live.com/volta/images/logo-volta.png" /&gt; &lt;/p&gt;&lt;p&gt;Ever wondered how to make web.config work in Volta first CTP release? Simply add a web.config file and add content to it? Unfortunately this is not the case in Volta at least in the first CTP. Five steps to get it done:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Add a web.config file &lt;/li&gt;&lt;li&gt;Add content to simply by copying from other web.config file &lt;/li&gt;&lt;li&gt;Right click on web.config from the Solution Explorer and then Properties &lt;/li&gt;&lt;li&gt;Choose Build Action to Embedded Resource &lt;/li&gt;&lt;li&gt;In your Volta Page Designer CS file, add the following line of code: &lt;/li&gt;&lt;/ol&gt;&lt;blockquote&gt;&lt;pre class="code"&gt;[&lt;span style="color:blue;"&gt;assembly&lt;/span&gt;: &lt;span style="color:#2b91af;"&gt;VoltaFile&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;"web.config"&lt;/span&gt;)]&lt;/pre&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt; &lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-5604288928324002178?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/5604288928324002178/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=5604288928324002178' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5604288928324002178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5604288928324002178'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/make-webconfig-work-in-volta.html' title='Make web.config work in Volta'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-4777834448087319014</id><published>2008-01-08T06:12:00.000-08:00</published><updated>2008-01-26T06:14:45.047-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>ASP.NET AJAX Best Practices: Avoid getters, setters</title><content type='html'>&lt;p&gt;Make minimum use of setters and getters if possible. Such accessors look like .NET like kind of beautiful properties, but these create new more scopes for JavaScript interpreter to deal with. If applicable, try directly setting/getting the private variable itself rather implementing methods for getters, setters.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-4777834448087319014?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/4777834448087319014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=4777834448087319014' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/4777834448087319014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/4777834448087319014'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-avoid.html' title='ASP.NET AJAX Best Practices: Avoid getters, setters'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-9040979624469679950</id><published>2008-01-07T00:30:00.000-08:00</published><updated>2008-01-26T00:31:17.737-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>ASP.NET AJAX Best Practices: Reduce scopes</title><content type='html'>&lt;p&gt;It's not pretty common. But, if you ever encounter such code, be sure it's a very bad practice. Introducing more scopes is a performance issue for JavaScript interpreter. It adds a new scope in the ladder. See the following sample scope:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;pageLoad()&lt;br /&gt;{&lt;br /&gt;    scope1();&lt;br /&gt;    &lt;span style="color: blue"&gt;function &lt;/span&gt;scope1()&lt;br /&gt;    {&lt;br /&gt;        alert(&lt;span style="color: #a31515"&gt;'scope1'&lt;/span&gt;);&lt;br /&gt;        scope2();&lt;br /&gt;        &lt;br /&gt;        &lt;span style="color: blue"&gt;function &lt;/span&gt;scope2()&lt;br /&gt;        {&lt;br /&gt;            alert(&lt;span style="color: #a31515"&gt;'scope2'&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}    &lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Introducing more scopes enforces the interpreter to go through new more sections in the scope chain that it maintains for code execution. So, unnecessary scopes reduce performance and it's a bad design too.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-9040979624469679950?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/9040979624469679950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=9040979624469679950' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9040979624469679950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9040979624469679950'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-reduce.html' title='ASP.NET AJAX Best Practices: Reduce scopes'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-387546908496939016</id><published>2008-01-06T00:11:00.000-08:00</published><updated>2008-01-26T00:19:57.010-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>ASP.NET AJAX Best Practices: Avoid using your own method while there is one</title><content type='html'>&lt;p&gt;Avoid implementing your own getElementById method that will cause script to DOM marshalling overhead. Each time you traverse the DOM and look for certain HTML element requires the JavaScript interpreter to marshalling script to DOM. It's always better to use getElementById of document object. So, before you write a function, make sure similar functionality can be achieved from some other built-in functions.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-387546908496939016?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/387546908496939016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=387546908496939016' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/387546908496939016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/387546908496939016'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-avoid-using_06.html' title='ASP.NET AJAX Best Practices: Avoid using your own method while there is one'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-9160496568652633638</id><published>2008-01-04T21:14:00.000-08:00</published><updated>2008-01-25T21:37:06.876-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>ASP.NET AJAX Best Practices: Careful with DOM element concatenation</title><content type='html'>&lt;p&gt;It's a very common bad practice. We often iterate through array, build HTML contents and keep on concatenating into certain DOM element. Every time you execute the block of code under the loop, you create the HTML markups, discover a div, access the innerHTML of a div, and for += operator you again discover the same div, access its innerHTML and concatenate it before assigning. &lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;pageLoad()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;var &lt;/span&gt;links = [&lt;span style="color: #a31515"&gt;&amp;quot;microsoft.com&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;tanzimsaqib.com&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;asp.net&amp;quot;&lt;/span&gt;];&lt;br /&gt;    &lt;br /&gt;    $get(&lt;span style="color: #a31515"&gt;'divContent'&lt;/span&gt;).innerHTML = &lt;span style="color: #a31515"&gt;'The following are my favorite sites:'&lt;br /&gt;    &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;links.length; ++i)&lt;br /&gt;        $get(&lt;span style="color: #a31515"&gt;'divContent'&lt;/span&gt;).innerHTML += &lt;span style="color: #a31515"&gt;'&amp;lt;a href=&amp;quot;http://www.' &lt;/span&gt;+ links[i] + &lt;span style="color: #a31515"&gt;'&amp;quot;&amp;gt;http://www.' &lt;/span&gt;+ links[i] + &lt;span style="color: #a31515"&gt;'&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;'&lt;/span&gt;;&lt;br /&gt;}  &lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;However, as you know accessing DOM element is one the costliest operation in JavaScript. So, it's wise to concatenate all HTML contents in a string and finally assign to the DOM element. That saves a lot of hard work for the browser.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;pageLoad()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;var &lt;/span&gt;links = [&lt;span style="color: #a31515"&gt;&amp;quot;microsoft.com&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;tanzimsaqib.com&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;asp.net&amp;quot;&lt;/span&gt;];&lt;br /&gt;    &lt;span style="color: blue"&gt;var &lt;/span&gt;content = &lt;span style="color: #a31515"&gt;'The following are my favorite sites:'&lt;br /&gt;    &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;i=0; i&amp;lt;links.length; ++i)&lt;br /&gt;        content += &lt;span style="color: #a31515"&gt;'&amp;lt;a href=&amp;quot;http://www.' &lt;/span&gt;+ links[i] + &lt;span style="color: #a31515"&gt;'&amp;quot;&amp;gt;http://www.' &lt;/span&gt;+ links[i] + &lt;span style="color: #a31515"&gt;'&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;'&lt;/span&gt;;&lt;br /&gt;        &lt;br /&gt;    $get(&lt;span style="color: #a31515"&gt;'divContent'&lt;/span&gt;).innerHTML = content;&lt;br /&gt;}  &lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-9160496568652633638?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/9160496568652633638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=9160496568652633638' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9160496568652633638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9160496568652633638'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-careful-with.html' title='ASP.NET AJAX Best Practices: Careful with DOM element concatenation'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-3978067615493859200</id><published>2008-01-03T21:03:00.000-08:00</published><updated>2008-01-25T21:05:16.450-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='AJAX'/><title type='text'>ASP.NET AJAX Best Practices: Use more "var"</title><content type='html'>&lt;p&gt;Less use of &amp;quot;var&amp;quot; can result into wrong calculation as well as mistake in logic control. And also JavaScript interpreter finds it hard to determine the scope of the variable if var is not used. Consider the following simple JavaScript code:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;pageLoad()&lt;br /&gt;{&lt;br /&gt;    i = 10;&lt;br /&gt;    loop();&lt;br /&gt;    alert(i);   &lt;span style="color: green"&gt;// here, i = 100&lt;br /&gt;&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;loop()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;for&lt;/span&gt;(i=0; i&amp;lt;100; ++i)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: green"&gt;// Some actions&lt;br /&gt;    &lt;/span&gt;}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Here you see, the loop uses the variable i used before in pageLoad. So, it brings a wrong result. Unlike .NET code, in JavaScript variables can go along with the method calls. So, better not confuse the interpreter by using more &amp;quot;var&amp;quot; in your code:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;pageLoad()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;&lt;strong&gt;var&lt;/strong&gt; &lt;/span&gt;i = 10;&lt;br /&gt;    loop();&lt;br /&gt;    alert(i);   &lt;span style="color: green"&gt;// here, i = 10&lt;br /&gt;&lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;loop()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;&lt;strong&gt;var&lt;/strong&gt; &lt;/span&gt;i=0; i&amp;lt;100; ++i)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: green"&gt;// Some actions&lt;br /&gt;    &lt;/span&gt;}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-3978067615493859200?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/3978067615493859200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=3978067615493859200' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3978067615493859200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3978067615493859200'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/aspnet-ajax-best-practices-use-more.html' title='ASP.NET AJAX Best Practices: Use more &amp;quot;var&amp;quot;'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-4647424893424245059</id><published>2008-01-03T00:12:00.000-08:00</published><updated>2008-01-17T00:22:50.732-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Volta'/><title type='text'>Make HTML controls discoverable in Volta Control</title><content type='html'>&lt;p&gt;&lt;img src="http://labs.live.com/volta/images/logo-volta.png" /&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;When a Volta control is rendered, the ID attribute of the generated HTML is changed to something like _vcId_1_DivName which is inconvenient to find from code. But the ID attribute stays the same in case of Volta Page, so it is discoverable by ID like this:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;Div &lt;/span&gt;divContent = Document.GetById&amp;lt;&lt;span style="color: #2b91af"&gt;Div&lt;/span&gt;&amp;gt;(&lt;span style="color: #a31515"&gt;&amp;quot;divContent&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;However, if you add HTML controls to the control like the following, the ID is not changed during the rendering:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public &lt;/span&gt;VoltaControl1() : &lt;span style="color: blue"&gt;base&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;VoltaControl1.html&amp;quot;&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;    InitializeComponent();&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #2b91af"&gt;Button &lt;/span&gt;btnClick = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Button&lt;/span&gt;();&lt;br /&gt;    btnClick.InnerText = &lt;span style="color: #a31515"&gt;&amp;quot;Click!&amp;quot;&lt;/span&gt;;&lt;br /&gt;    btnClick.Id = &lt;span style="color: #a31515"&gt;&amp;quot;btnClick&amp;quot;&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: blue"&gt;this&lt;/span&gt;.Add(btnClick);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you don't prefer this way and seriously want to write your own HTML in the control's html page, you might find the following snippet useful. But, remember in this case you will use name attribute of the html element instead of ID.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: green"&gt;// Usage: var element = GetElementByName(Document.GetElementsByTagName(&amp;quot;div&amp;quot;), &amp;quot;divWidget&amp;quot;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;HtmlElement &lt;/span&gt;GetElementByName(&lt;span style="color: #2b91af"&gt;HtmlElementCollection &lt;/span&gt;elements, &lt;span style="color: blue"&gt;string &lt;/span&gt;name)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;element &lt;span style="color: blue"&gt;in &lt;/span&gt;elements)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: #2b91af"&gt;DomAttribute &lt;/span&gt;nameAttribute = element.Attributes.GetNamedItem(&lt;span style="color: #a31515"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(nameAttribute != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(nameAttribute.Value == name)&lt;br /&gt;                &lt;span style="color: blue"&gt;return &lt;/span&gt;element;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;return null&lt;/span&gt;;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-4647424893424245059?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/4647424893424245059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=4647424893424245059' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/4647424893424245059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/4647424893424245059'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/make-html-controls-discoverable-in.html' title='Make HTML controls discoverable in Volta Control'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-3079607831475881925</id><published>2008-01-02T22:49:00.000-08:00</published><updated>2008-01-16T22:56:00.257-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Volta'/><title type='text'>Making cross domain AJAX call using Volta</title><content type='html'>&lt;p&gt;&lt;img src="http://labs.live.com/volta/images/logo-volta.png" /&gt; &lt;/p&gt;&lt;p&gt;Making a cross domain AJAX call in Volta is piece of cake. Volta compiler generates necessary client codes to make it work. Here is a snippet that can make an AJAX call to some Url and fetch data:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;public void &lt;/span&gt;DownloadPhotos()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color:#2b91af;"&gt;IHttpRequest &lt;/span&gt;request = &lt;span style="color:#2b91af;"&gt;HttpRequestFactory&lt;/span&gt;.Create();&lt;br /&gt;    request.AsyncSend(&lt;span style="color:#a31515;"&gt;"POST"&lt;/span&gt;, URL, &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Empty,&lt;br /&gt;        &lt;span style="color:blue;"&gt;delegate&lt;/span&gt;(&lt;span style="color:blue;"&gt;string &lt;/span&gt;response)&lt;br /&gt;        {&lt;br /&gt;            OnPhotosLoaded(&lt;span style="color:blue;"&gt;new &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;PhotosLoadedEventArgs&lt;/span&gt;(response));&lt;br /&gt;        });&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Both IHttpRequest and HttpRequestFactory classes can be found in the Microsoft.LiveLabs.Volta.MultiTier namespace. AsyncSend method performs the asynchronous call and calls back the delegate defined where OnPhotosLoaded event is fired to notify the subscriber of this event that the data has just arrived.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-3079607831475881925?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/3079607831475881925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=3079607831475881925' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3079607831475881925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3079607831475881925'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/making-cross-domain-ajax-call-using.html' title='Making cross domain AJAX call using Volta'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-6285589321186228552</id><published>2008-01-01T11:00:00.000-08:00</published><updated>2008-01-11T11:02:22.652-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Namespace Alias Qualifier - to get rid of crazy coding</title><content type='html'>&lt;p&gt;Let us say somebody in your company loves crazy coding and really do not bother about his/her codes affect others. (S)He put class name System and a constant Console and now wondering how come a simple Console.WriteLine does not compile:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;System&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;int &lt;/span&gt;Console = 10;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;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: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;); &lt;span style="color: green"&gt;// Compile time error&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;System&lt;/span&gt;.Console.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;); &lt;span style="color: green"&gt;// Compile time error&lt;br /&gt;    &lt;/span&gt;}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Making use of global::System.Console must solve your problem:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;System&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;int &lt;/span&gt;Console = 10;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;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;global&lt;/span&gt;::System.&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;);&lt;br /&gt;        &lt;span style="color: blue"&gt;global&lt;/span&gt;::System.&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;); &lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;However, ever thought of a scenario where there can be same class name under two different namespaces? Here comes the role of Namespace Alias Qualifier. In namespace declaration by &amp;quot;using&amp;quot;, aliases can be assigned to namespaces so that they might be useful in later part of the code as shorthand and most importantly will solve the problem of ambiguity: &lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;sys = System;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;mine = MyProject.Process;&lt;br /&gt;...&lt;br /&gt;...&lt;br /&gt;sys.Console.WriteLine(mine.Console[&lt;span style="color: #a31515"&gt;&amp;quot;width&amp;quot;&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/5430732659644493117-6285589321186228552?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/6285589321186228552/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=6285589321186228552' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/6285589321186228552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/6285589321186228552'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/namespace-alias-qualifier-to-get-rid-of.html' title='Namespace Alias Qualifier - to get rid of crazy coding'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-8025580150501477636</id><published>2007-12-03T13:19:00.000-08:00</published><updated>2008-01-09T13:21:47.209-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><title type='text'>Anonymous types: var</title><content type='html'>&lt;p&gt;Anonymous types are excellent addition to .NET &amp;#8220;Orcas&amp;#8221; release. These are a convenient language feature that allows developers to write code without bothering about what particular type of object they are dealing with. Anonymous types are declared by var keyword which you most of the times will see in different application of LINQ. It's true it great use with LINQ, but it's not a LINQ feature at all - it's a new language feature.&lt;/p&gt;  &lt;p&gt;A very simple use of Anonymous types is (starting with a keyword var):&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;helo = 123;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You can assign whatever type you like. But, unlike JavaScript once you assigned one type of value, you cannot assign to other types like this:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;helo = 123;&lt;br /&gt;helo = &lt;span style="color: #a31515"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Again, unlike JavaScript, you cannot left a declaration unassigned. Do not ever mix up with JavaScript's var and .NET's one. &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;helo;   &lt;span style="color: green"&gt;// It won't compile&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Take a look at variety of usage of Anonymous types. Enjoy the powerful Visual Studio's great intellisense:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;helo = 123;&lt;br /&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(helo.Equals(123));&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;hello = &lt;span style="color: #a31515"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(hello.Length);&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;helloWorld = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;&amp;gt;() { &lt;span style="color: #a31515"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;world&amp;quot; &lt;/span&gt;};&lt;br /&gt;helloWorld.ForEach(&lt;span style="color: blue"&gt;delegate&lt;/span&gt;(&lt;span style="color: blue"&gt;string &lt;/span&gt;x) { &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(x); });&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If we consider the performance issue, there's no extra footprint on CLR for Anonymous types. Before it goes to CLR's hands, vars are replaced with appropriate type so there's no extra effort for CLR to understand the types:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;var &lt;/span&gt;hello = &lt;span style="color: #a31515"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;;    &lt;span style="color: green"&gt;// exactly same as: string hello = &amp;quot;hello&amp;quot;;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Anonymous types are not only appropriate for lazy developers like me, but also have great effective usage in LINQ. I'll cover that one may be later sometime.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-8025580150501477636?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/8025580150501477636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=8025580150501477636' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/8025580150501477636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/8025580150501477636'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2007/12/anonymous-types-var_03.html' title='Anonymous types: var'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-9102246785485605354</id><published>2007-10-12T14:06:00.000-07:00</published><updated>2008-01-09T13:07:26.634-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>LINQ: Iterate through collection which implements IEnumerable only</title><content type='html'>&lt;p&gt;The following works fine in LINQ, because an array implements IEnumerable &amp;lt;T&amp;gt;.    &lt;br /&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt;[] tokenArray = &lt;span style="color: blue"&gt;new string&lt;/span&gt;[2] { &lt;span style="color: #a31515"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;World&amp;quot; &lt;/span&gt;}; &lt;br /&gt;var tokens = from token &lt;span style="color: blue"&gt;in &lt;/span&gt;tokenList select token;              &lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;foreach &lt;/span&gt;(var item &lt;span style="color: blue"&gt;in &lt;/span&gt;tokens) &lt;br /&gt;    Console.WriteLine(item);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;  &lt;br /&gt;But, the collections which do not implement IEnumerable&amp;lt;T&amp;gt; or IQueryable, can not be iterated in LINQ in the same way. To achieve the same, make use of a simple casting trick such as: &lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;ArrayList tokenList = &lt;span style="color: blue"&gt;new &lt;/span&gt;ArrayList(); &lt;br /&gt;tokenList.Add(&lt;span style="color: #a31515"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;); &lt;br /&gt;tokenList.Add(&lt;span style="color: #a31515"&gt;&amp;quot;World&amp;quot;&lt;/span&gt;);              &lt;br /&gt;&lt;br /&gt;var tokens = from &lt;span style="color: blue"&gt;&lt;strong&gt;string&lt;/strong&gt; &lt;/span&gt;token &lt;span style="color: blue"&gt;in &lt;/span&gt;tokenList select token;              &lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;foreach &lt;/span&gt;(var item &lt;span style="color: blue"&gt;in &lt;/span&gt;tokens) &lt;br /&gt;    Console.WriteLine(item);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;  &lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&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/5430732659644493117-9102246785485605354?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/9102246785485605354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=9102246785485605354' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9102246785485605354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/9102246785485605354'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2007/10/linq-iterate-through-collection-which.html' title='LINQ: Iterate through collection which implements IEnumerable only'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-3999730173947604271</id><published>2007-03-16T14:03:00.000-07:00</published><updated>2008-01-09T13:05:05.997-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Vista'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>SQL Server Full Text Search service running problem in Windows Vista</title><content type='html'>&lt;p&gt;I use Windows Vista Business with all features turned on. When I installed SQL Server 2005 Developer Edition, I found Full Text Search service can't start itself. I tried running it from Management Console -&amp;gt; Services. It still fails with message: &amp;quot;The dependency service does not exist or has been marked for deletion.&amp;quot;&lt;/p&gt;  &lt;p&gt;So, what I did to remove the dependencies:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Opened Registry Editor (regedit.exe) &lt;/li&gt;    &lt;li&gt;Went to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\msftesql$SQLSERVER &lt;/li&gt;    &lt;li&gt;Removed the contents (Data) of DependOnService key &lt;/li&gt;    &lt;li&gt;Rebooted. Now works fine. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I wasn't sure what particular dependencies were culprit, so I removed all and it works fine. Another thing to remember when you'll see any correct FullText SQL isn't working, check if the FullText service is running smoothly&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-3999730173947604271?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/3999730173947604271/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=3999730173947604271' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3999730173947604271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/3999730173947604271'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2007/03/sql-server-full-text-search-service.html' title='SQL Server Full Text Search service running problem in Windows Vista'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-4328003513707060338</id><published>2007-03-13T00:44:00.000-07:00</published><updated>2008-01-16T22:27:25.327-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Selenium'/><title type='text'>Setting up PHP environment for Selenium</title><content type='html'>&lt;p&gt;If you have gone through configuring Selenium in Windows system by &lt;a href="http://tanzimsaqib.com/setting-up-selenium-rc-server-in-windows/"&gt;Setting up Selenium RC server in Windows&lt;/a&gt; and &lt;a href="http://tanzimsaqib.com/setting-up-php-in-windows-using-abyss-server/"&gt;Setting up PHP in Windows using Abyss server&lt;/a&gt;, next thing you need to setup is the Selenium PHP client. Let me show you the steps I've gone through to accomplish this:&lt;/p&gt;&lt;p&gt;1. Open up the console with all administrative privileges especially in Vista&lt;br /&gt;2. Go to the directory where PHP is installed&lt;br /&gt;3. Execute command: php PEAR/go-pear.phar&lt;br /&gt;4. Follow the instructions, and ignore the additional offerings to configure it&lt;br /&gt;5. Install PHPUnit by:&lt;br /&gt;          pear channel-discover pear.phpunit.de&lt;br /&gt;          pear install phpunit/PHPUnit&lt;/p&gt;&lt;p&gt;6. &lt;a title="Testing_Selenium" href="http://pear.php.net/package/Testing_Selenium"&gt;Download&lt;/a&gt; Selenium PHP PEAR extension and place into your PHP directory&lt;br /&gt;7. Run: pear install Testing_Selenium-0.4.2.tar&lt;br /&gt;8. &lt;a title="GoogleTest.php" href="http://svn.openqa.org/fisheye/viewrep/~raw,r=HEAD/selenium-rc/trunk/clients/php/GoogleTest.php"&gt;Download&lt;/a&gt; the sample GoogleTest and assuming you put it in C:\Tests folder&lt;br /&gt;9. Now run: phpunit --verbose GoogleTest C:/Tests/GoogleTest.php&lt;br /&gt;10. Remember the class name GoogleTest must be the same as the class name defined in the GoogleTest.php&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-4328003513707060338?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/4328003513707060338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=4328003513707060338' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/4328003513707060338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/4328003513707060338'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/setting-up-php-environment-for-selenium.html' title='Setting up PHP environment for Selenium'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-7239679608385726628</id><published>2007-03-11T23:31:00.000-07:00</published><updated>2008-01-16T22:32:09.754-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Selenium'/><title type='text'>Setting up PHP in Windows using Abyss server</title><content type='html'>&lt;p&gt;&lt;strong&gt;Reason behind installing another server to your system      &lt;br /&gt;&lt;/strong&gt;Whichever platform you have been working with must using a server. For .NET developers, IIS eases all the pain. So, what is now if you must install PHP in your system side by side .NET. I suggest you not to install PHP in the same server the .NET is working in. So, install another server which will work with all burdens of PHP stuffs.     &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Why Abyss?      &lt;br /&gt;&lt;/strong&gt;The reasons behind choosing this server is Abyss is free, easy to configure, very lightweight, and small to download at only 344KB. It also has a preconfigured PHP version for them with all official extensions.     &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;Step by Step      &lt;br /&gt;&lt;/strong&gt;1. &lt;a href="http://www.aprelium.com/abyssws/download.php" target="_blank"&gt;Download&lt;/a&gt; Abyss server, and install with default settings. &lt;a href="http://www.aprelium.com/abyssws/php5win.html" target="_blank"&gt;Download&lt;/a&gt; and install preconfigured PHP version for Abyss     &lt;br /&gt;2. Hit this URL in your browser: &lt;a href="http://127.0.0.1:9999/console/language"&gt;http://127.0.0.1:9999/console/language&lt;/a&gt;     &lt;br /&gt;3. Choose your preferred language     &lt;br /&gt;4. Enter your chosen user name and password for the server, and click OK.     &lt;br /&gt;5. It will then ask your user name and password again, enter the credential and press OK. You will see the following screen:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.google.com/saqib1984/R472SvnDPcI/AAAAAAAAABU/DX_eW-EF9QA/clip_image0024"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="265" alt="clip_image002" src="http://lh4.google.com/saqib1984/R472TvnDPdI/AAAAAAAAABg/nK603iuCPu0/clip_image002_thumb1" width="401" border="0" /&gt;&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;6. Click on &amp;#8220;Configure&amp;#8221; from the Hosts table. You will find the following screen:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.google.com/saqib1984/R472VPnDPeI/AAAAAAAAABo/XJF-uR-aAHM/clip_image00257"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="351" alt="clip_image002[5]" src="http://lh3.google.com/saqib1984/R472WfnDPfI/AAAAAAAAABw/yiLhVwG6Jkw/clip_image0025_thumb5" width="401" border="0" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;7. Click on &amp;#8220;Scripting Parameters&amp;#8221;.    &lt;br /&gt;8. You will find the following Interpreters table, click &amp;#8220;Add&amp;#8221;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.google.com/saqib1984/R472XfnDPgI/AAAAAAAAAB4/xiiVJai6kHQ/clip_image00273"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="103" alt="clip_image002[7]" src="http://lh3.google.com/saqib1984/R472YfnDPhI/AAAAAAAAACA/din6TQBrjHw/clip_image0027_thumb1" width="401" border="0" /&gt;&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;9. Set the Interface drop down to: FastCGI (Local - Pipes).     &lt;br /&gt;10. In interpreter field set the path: C:\Program Files\PHP5\php-cgi.exe if you have installed PHP in C:\ Program Files     &lt;br /&gt;11. Set Type drop down to PHP Style.     &lt;br /&gt;12. Make sure &amp;quot;Use the associated extensions to automatically update the Script Paths&amp;quot; is checked.     &lt;br /&gt;13. Click &amp;#8220;Add&amp;#8221; in Associated Extensions table:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.google.com/saqib1984/R472ZPnDPiI/AAAAAAAAACI/9z8WtA3wDD8/clip_image00293"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="99" alt="clip_image002[9]" src="http://lh6.google.com/saqib1984/R472aPnDPjI/AAAAAAAAACQ/bZswOvjiVTU/clip_image0029_thumb1" width="397" border="0" /&gt;&lt;/a&gt;     &lt;br /&gt;    &lt;br /&gt;14. Type php in the extension field and pesss OK. Press two more OK.     &lt;br /&gt;15. Click on &amp;#8220;Restart&amp;#8221; to restart the server so that configuration changes can take effect.     &lt;br /&gt;16. If you have installed Abyss Server in C:\Program Files, we will have to deploy your web files inside C:\Program Files\Abyss Web Server\htdocs to make it work.     &lt;br /&gt;17. Your server address will be &lt;a href="http://localhost:8000/"&gt;http://localhost:8000/&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/5430732659644493117-7239679608385726628?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/7239679608385726628/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=7239679608385726628' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/7239679608385726628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/7239679608385726628'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2007/03/setting-up-php-in-windows-using-abyss.html' title='Setting up PHP in Windows using Abyss server'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-200978763159502572</id><published>2007-03-11T21:20:00.000-07:00</published><updated>2008-01-16T22:26:47.024-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Test'/><category scheme='http://www.blogger.com/atom/ns#' term='Selenium'/><title type='text'>Setting up Selenium RC server in Windows</title><content type='html'>&lt;p&gt;1. Download latest Java SE from &lt;a title="http://java.sun.com/" href="http://java.sun.com/"&gt;http://java.sun.com/&lt;/a&gt; and install&lt;/p&gt;&lt;p&gt;2. &lt;a title="Download" href="http://openqa.org/selenium-rc/download.action"&gt;Download&lt;/a&gt; latest version of Selenium RC from and extract&lt;/p&gt;&lt;p&gt;3. Create a folder named Selenium at C:\Program Files\Java\jdk1.6.0_03\bin&lt;/p&gt;&lt;p&gt;4. Copy all files under Selenium-server-0.9.2 which you will find in the extracted folder and paste in the newly created folder&lt;/p&gt;&lt;p&gt;5. From Command prompt run the following commands:&lt;/p&gt;&lt;p&gt;cd \&lt;br /&gt;cd C:\PROGRA~1\Java\jdk1.6.0_03\bin&lt;br /&gt;java -jar .\Selenium\selenium-server.jar -interactive &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;If you see the following messages at the end of the console, you are quite confirm that the Selenium server is running fine: &lt;/p&gt;&lt;p&gt;Entering interactive mode... type Selenium commands here (e.g: cmd=open&amp;amp;1=http:/&lt;br /&gt;/www.yahoo.com)&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-200978763159502572?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/200978763159502572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=200978763159502572' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/200978763159502572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/200978763159502572'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2008/01/setting-up-selenium-rc-server-in.html' title='Setting up Selenium RC server in Windows'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-1109052273673384201</id><published>2007-02-06T12:58:00.000-08:00</published><updated>2008-01-09T13:02:44.294-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>JavaScript execution before the page has finished loading</title><content type='html'>&lt;p&gt;When a webpage loads, it fetches the stylesheets, javascript, images, other objects etc. So, when it is done, it's already late and user may complain about the site's poor speed of execution. One way you can make it faster, you can start JavaScript execution immediately right after the HTML DOM has finished loading and ready to traverse, before the images.    &lt;br /&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: green"&gt;// Introduce our custom event onDOMReady &lt;br /&gt;&lt;/span&gt;window.onDOMReady = DOMReady  &lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;DOMReady(fn) &lt;br /&gt;{ &lt;br /&gt;    &lt;span style="color: green"&gt;// According to standard implementation &lt;br /&gt;     &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt;(document.addEventListener) &lt;br /&gt;        document.addEventListener(&lt;span style="color: #a31515"&gt;&amp;quot;DOMContentLoaded&amp;quot;&lt;/span&gt;, fn, &lt;span style="color: blue"&gt;false&lt;/span&gt;);  &lt;br /&gt;&lt;br /&gt;    &lt;span style="color: green"&gt;// IE &lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;else &lt;br /&gt;        &lt;/span&gt;document.onreadystatechange = &lt;span style="color: blue"&gt;function&lt;/span&gt;() &lt;br /&gt;            { &lt;br /&gt;                checkReadyState(fn); &lt;br /&gt;            } &lt;br /&gt;}  &lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;function &lt;/span&gt;checkReadyState(fn) &lt;br /&gt;{ &lt;br /&gt;    &lt;span style="color: blue"&gt;if&lt;/span&gt;(document.readyState == &lt;span style="color: #a31515"&gt;&amp;quot;interactive&amp;quot;&lt;/span&gt;) &lt;br /&gt;        fn(); &lt;br /&gt;}  &lt;br /&gt;&lt;br /&gt;window.onDOMReady( &lt;br /&gt;    &lt;span style="color: blue"&gt;function&lt;/span&gt;() &lt;br /&gt;    { &lt;br /&gt;        &lt;span style="color: green"&gt;// DOM is loaded &lt;br /&gt;        // So start JavaScript execution &lt;br /&gt;    &lt;/span&gt;} &lt;br /&gt;);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;  &lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&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/5430732659644493117-1109052273673384201?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/1109052273673384201/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=1109052273673384201' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/1109052273673384201'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/1109052273673384201'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2007/02/javascript-execution-before-page-has.html' title='JavaScript execution before the page has finished loading'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5430732659644493117.post-5585953417206459836</id><published>2006-12-27T12:51:00.000-08:00</published><updated>2008-01-09T12:52:54.830-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lifestyle'/><title type='text'>Time leverage</title><content type='html'>&lt;p&gt;How much time can we save in a day? No matter how motivated or educated a person is, he or she still only has 24 hours in a day, so how do they use those hours to get so much more output than the average person? &lt;/p&gt;  &lt;p&gt;A lever is a device that multiplies the effort applied. Archimedes once stated: If I had a lever long enough I could move the world. The concept is the same for the better output. If we apply enough leverage then we can achieve more than any level of productivity that we imagine. &lt;/p&gt;  &lt;p&gt;Time is the most valuable resource that we have. We each have exactly the same amount each day (24 hours). The successful people do not think in terms of saving time they think in terms of leveraging time. In other words they are constantly looking for better answers to the question: how can I get better productivity in each 24 hour period? This is the essential question that we need to answer in order to discover how to best leverage our own time. &lt;/p&gt;  &lt;p&gt;This post you are reading now is a perfect example of leveraging time. It requires only a small amount of time for me to write, because it is published on the blog, hundreds of people will read the post. If I were to teach what is in the post to each person individually then it would require months of my time, yet I achieve the same teaching in the short time it takes to write the post. The post is a time lever as well as the internet. &lt;/p&gt;  &lt;p&gt;Time saving for work is very important, but it will limit your productivity only to the hours you saved. On the other hand, time leveraging allows you to multiply the effort applied exceeding that limit if you always look for how to leverage best. However, it always requires experience to choose one's best strategy for time leveraging. For example, I used to keep track of my personal finance history on a diary. Time came when I could not manage to do it regularly and had to stop for a while since I was busy with some other very important tasks. Eventually it turned out to be useless for me after few days. Then I looked for software for such purpose. It didn't even work after few weeks. So, I looked more and found few cool mobile applications so that I now can manage my finance even on the road in least possible time with greater ease. Ultimately it turned out to be the most efficient way to smartly manage my finance.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5430732659644493117-5585953417206459836?l=tanzim-saqib.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tanzim-saqib.blogspot.com/feeds/5585953417206459836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5430732659644493117&amp;postID=5585953417206459836' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5585953417206459836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5430732659644493117/posts/default/5585953417206459836'/><link rel='alternate' type='text/html' href='http://tanzim-saqib.blogspot.com/2006/12/time-leverage.html' title='Time leverage'/><author><name>Tanzim Saqib</name><uri>http://www.blogger.com/profile/01971653644826490824</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
