<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Tanzim Saqib on .NET discovery &#187; ASP.NET</title>
	<atom:link href="http://tanzimsaqib.wordpress.com/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://tanzimsaqib.wordpress.com</link>
	<description>Innovate. Create. Share.</description>
	<lastBuildDate>Wed, 19 Nov 2008 10:04:28 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='tanzimsaqib.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/756ba5f132c23525771f86885e65d27c?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Tanzim Saqib on .NET discovery &#187; ASP.NET</title>
		<link>http://tanzimsaqib.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://tanzimsaqib.wordpress.com/osd.xml" title="Tanzim Saqib on .NET discovery" />
		<item>
		<title>CallQueue: Implementing a Sequential Web Service Call Queue for AJAX application</title>
		<link>http://tanzimsaqib.wordpress.com/2008/11/19/callqueue-implementing-a-sequential-web-service-call-queue-for-ajax-application/</link>
		<comments>http://tanzimsaqib.wordpress.com/2008/11/19/callqueue-implementing-a-sequential-web-service-call-queue-for-ajax-application/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 10:04:28 +0000</pubDate>
		<dc:creator>tanzimsaqib</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://tanzimsaqib.wordpress.com/2008/11/19/callqueue-implementing-a-sequential-web-service-call-queue-for-ajax-application/</guid>
		<description><![CDATA[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 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=101&subd=tanzimsaqib&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>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. </p>
<p><strong>The Specification<br /></strong>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:</p>
<ul>
<li>Enqueue any WebService call anytime in the application.
<li>Dequeue any previously queued call regardless of currently executing call and location in the application.
<li>Each WebService call should have an identifier so that we can track the call and dequeue anytime later by SSQ.dq(call_id).
<li>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.
<li>A timer will act as scheduler but will not run forever. It should run only when necessary.
<li>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.
<li>notifyCompleted should also be optional. The currently running call should automatically be dequeued from the scheduler queue after the timeout of its own.
<li>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.
<li>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.</li>
</ul>
<p><strong>The Usage<br /></strong>You should be able to use this library as follows:</p>
<ol>
<li>Include GenericQueue.js and SequentialServiceQueue.js to your project
<li>Add the reference in the pages that you want them to be used</li>
</ol>
<p>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:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:fc2046a6-27d0-4752-a768-75c189e3c3e0" class="wlWriterSmartContent">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#0000FF;">var</span><span style="color:#000000;"> id1 </span><span style="color:#000000;">=</span><span style="color:#000000;"> SSQ.nq(</span><span style="color:#000000;">'</span><span style="color:#000000;">SomeMethod1</span><span style="color:#000000;">'</span><span style="color:#000000;">, </span><span style="color:#0000FF;">false</span><span style="color:#000000;">, </span><span style="color:#000000;">1000</span><span style="color:#000000;">,
    </span><span style="color:#0000FF;">function</span><span style="color:#000000;">()
    {
        </span><span style="color:#008000;">//</span><span style="color:#008000;"> Do some stuffs</span><span style="color:#008000;">
</span><span style="color:#000000;">        SomeWebService1.SomeMethod1(SomeParameters, onSomeMethodCallCompleted);
    });

</span><span style="color:#0000FF;">function</span><span style="color:#000000;"> onSomeMethodCallCompleted(result)
{
    </span><span style="color:#008000;">//</span><span style="color:#008000;"> Do stuffs</span><span style="color:#008000;">
</span><span style="color:#000000;">    SSQ.notifyCompleted(id1);
}

</span><span style="color:#0000FF;">var</span><span style="color:#000000;"> id2 </span><span style="color:#000000;">=</span><span style="color:#000000;"> SSQ.nq(</span><span style="color:#000000;">'</span><span style="color:#000000;">SomeMethod2</span><span style="color:#000000;">'</span><span style="color:#000000;">, </span><span style="color:#0000FF;">false</span><span style="color:#000000;">, </span><span style="color:#000000;">1000</span><span style="color:#000000;">,
    </span><span style="color:#0000FF;">function</span><span style="color:#000000;">()
    {
        </span><span style="color:#008000;">//</span><span style="color:#008000;"> Do some stuffs</span><span style="color:#008000;">
</span><span style="color:#000000;">        SomeWebService2.SomeMethod2(SomeParameters,
            </span><span style="color:#0000FF;">function</span><span style="color:#000000;">(result)
            {
                </span><span style="color:#008000;">//</span><span style="color:#008000;"> Do stuffs</span><span style="color:#008000;">
</span><span style="color:#000000;">                SSQ.notifyCompleted(id2);
            });
    });</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>You can not only queue WebService calls, but also regular JavaScript codeblock:</p>
<div style="width:619px;display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:27c0c167-37c3-4e49-a541-ba0fa9b18eb8" class="wlWriterSmartContent">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#0000FF;">var</span><span style="color:#000000;"> service_id1 </span><span style="color:#000000;">=</span><span style="color:#000000;"> SSQ.nq(</span><span style="color:#000000;">'</span><span style="color:#000000;">Service1</span><span style="color:#000000;">'</span><span style="color:#000000;">, </span><span style="color:#0000FF;">false</span><span style="color:#000000;">, </span><span style="color:#000000;">1000</span><span style="color:#000000;">,
    </span><span style="color:#0000FF;">function</span><span style="color:#000000;">()
    {
        </span><span style="color:#008000;">//</span><span style="color:#008000;"> Do some stuffs</span><span style="color:#008000;">
</span><span style="color:#000000;">        SSQ.notifyCompleted(service_id1);
    });</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p><strong>The GenericQueue<br /></strong>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:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:3376f21b-d36c-474a-9973-b2befdf1374e" class="wlWriterSmartContent">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#0000FF;">this</span><span style="color:#000000;">.nq </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">function</span><span style="color:#000000;">(element)
{
    array.push(element);
    </span><span style="color:#000000;">++</span><span style="color:#000000;">rear;
}

</span><span style="color:#0000FF;">this</span><span style="color:#000000;">.dq </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">function</span><span style="color:#000000;">()
{
    </span><span style="color:#0000FF;">var</span><span style="color:#000000;"> element </span><span style="color:#000000;">=</span><span style="color:#000000;"> undefined;

    </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (</span><span style="color:#000000;">!</span><span style="color:#0000FF;">this</span><span style="color:#000000;">.is_empty())
    {
        element </span><span style="color:#000000;">=</span><span style="color:#000000;"> array.shift();
        </span><span style="color:#000000;">--</span><span style="color:#000000;">rear;
    }

    </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> element;
}

</span><span style="color:#0000FF;">this</span><span style="color:#000000;">.for_each </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">function</span><span style="color:#000000;">(func)
{
    </span><span style="color:#0000FF;">for</span><span style="color:#000000;"> (</span><span style="color:#0000FF;">var</span><span style="color:#000000;"> i </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#000000;">0</span><span style="color:#000000;">; i </span><span style="color:#000000;">&lt;</span><span style="color:#000000;"> rear; </span><span style="color:#000000;">++</span><span style="color:#000000;">i)
        func(i, array[i]);
}

</span><span style="color:#0000FF;">this</span><span style="color:#000000;">.delete_at </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">function</span><span style="color:#000000;">(index)
{
    </span><span style="color:#0000FF;">delete</span><span style="color:#000000;"> array[index];

    </span><span style="color:#0000FF;">var</span><span style="color:#000000;"> i </span><span style="color:#000000;">=</span><span style="color:#000000;"> index;
    </span><span style="color:#0000FF;">while</span><span style="color:#000000;"> (i </span><span style="color:#000000;">&lt;</span><span style="color:#000000;"> array.length)
        array[i] </span><span style="color:#000000;">=</span><span style="color:#000000;"> array[</span><span style="color:#000000;">++</span><span style="color:#000000;">i];

    array </span><span style="color:#000000;">=</span><span style="color:#000000;"> array.slice(</span><span style="color:#000000;">0</span><span style="color:#000000;">, </span><span style="color:#000000;">--</span><span style="color:#000000;">rear);
}</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p><strong>The SequentialServiceQueue</strong><br />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.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:b4286d51-b175-49f5-8944-59bed7e1fd96" class="wlWriterSmartContent">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#0000FF;">var</span><span style="color:#000000;"> SequentialServiceQueue </span><span style="color:#000000;">=</span><span style="color:#000000;">
{
    timer_id: </span><span style="color:#0000FF;">null</span><span style="color:#000000;">,
    ms_when_last_call_made: </span><span style="color:#000000;">0</span><span style="color:#000000;">,          </span><span style="color:#008000;">//</span><span style="color:#008000;"> milliseconds (readonly)</span><span style="color:#008000;">
</span><span style="color:#000000;">    ms_elapsed_since_last_call: </span><span style="color:#000000;">0</span><span style="color:#000000;">,      </span><span style="color:#008000;">//</span><span style="color:#008000;"> milliseconds (readonly)</span><span style="color:#008000;">
</span><span style="color:#000000;">    running_task: </span><span style="color:#0000FF;">null</span><span style="color:#000000;">,
    interval: </span><span style="color:#000000;">10</span><span style="color:#000000;">,                       </span><span style="color:#008000;">//</span><span style="color:#008000;"> milliseconds</span><span style="color:#008000;">
</span><span style="color:#000000;">    queue: </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> GenericQueue(),

    get_random_id: </span><span style="color:#0000FF;">function</span><span style="color:#000000;">() {
        </span><span style="color:#0000FF;">var</span><span style="color:#000000;"> min </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#000000;">1</span><span style="color:#000000;">;
        </span><span style="color:#0000FF;">var</span><span style="color:#000000;"> max </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#000000;">10</span><span style="color:#000000;">;
        </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> Date().getTime() </span><span style="color:#000000;">+</span><span style="color:#000000;"> (Math.round((max </span><span style="color:#000000;">-</span><span style="color:#000000;"> min) </span><span style="color:#000000;">*</span><span style="color:#000000;"> Math.random() </span><span style="color:#000000;">+</span><span style="color:#000000;"> min));
    },</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>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.</p>
</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ae7c30d7-43e7-4af0-8770-8f7883c4cc68" class="wlWriterSmartContent">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#000000;">nq: </span><span style="color:#0000FF;">function</span><span style="color:#000000;">(name, replaceIfExists, timeout, code) {
    </span><span style="color:#0000FF;">var</span><span style="color:#000000;"> id </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.get_random_id();

    </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (replaceIfExists) {
        </span><span style="color:#0000FF;">var</span><span style="color:#000000;"> isFound </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">false</span><span style="color:#000000;">;
        </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.queue.for_each(
            </span><span style="color:#0000FF;">function</span><span style="color:#000000;">(index, element) {
                </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (element </span><span style="color:#000000;">!==</span><span style="color:#000000;"> undefined </span><span style="color:#000000;">&amp;&amp;</span><span style="color:#000000;"> element </span><span style="color:#000000;">!==</span><span style="color:#000000;"> </span><span style="color:#000000;">'</span><span style="color:#000000;">undefined</span><span style="color:#000000;">'</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;&amp;</span><span style="color:#000000;"> element.name </span><span style="color:#000000;">==</span><span style="color:#000000;"> name) {
                    element.id </span><span style="color:#000000;">=</span><span style="color:#000000;"> id;
                    element.replaceIfExists </span><span style="color:#000000;">=</span><span style="color:#000000;"> replaceIfExists;
                    element.timeout </span><span style="color:#000000;">=</span><span style="color:#000000;"> timeout;
                    element.code </span><span style="color:#000000;">=</span><span style="color:#000000;"> code;
                    isFound </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">true</span><span style="color:#000000;">;
                }
            });
    }

    </span><span style="color:#008000;">//</span><span style="color:#008000;"> Enqueue new task</span><span style="color:#008000;">
</span><span style="color:#000000;">    </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (</span><span style="color:#000000;">!</span><span style="color:#000000;">isFound </span><span style="color:#000000;">||</span><span style="color:#000000;"> </span><span style="color:#000000;">!</span><span style="color:#000000;">replaceIfExists) {
        </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.queue.nq(
            {
                id: id,
                name: name,
                replaceIfExists: replaceIfExists,
                timeout: timeout,
                code: code
            });
    }

    </span><span style="color:#008000;">//</span><span style="color:#008000;"> We have got new tasks, start the updater</span><span style="color:#008000;">
</span><span style="color:#000000;">    </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.startUpdater();

    </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> id;
},</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>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.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:1696cc4d-c248-4621-9489-a8f1c75ff909" class="wlWriterSmartContent">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#000000;">detachTask: </span><span style="color:#0000FF;">function</span><span style="color:#000000;">(id) {
    </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.dq(id);
    </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.running_task </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;">;
    </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.ms_when_last_call_made </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#000000;">0</span><span style="color:#000000;">;
    </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.ms_elapsed_since_last_call </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#000000;">0</span><span style="color:#000000;">;

    </span><span style="color:#008000;">//</span><span style="color:#008000;"> See if we are done with the queued tasks</span><span style="color:#008000;">
</span><span style="color:#000000;">    </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (</span><span style="color:#0000FF;">this</span><span style="color:#000000;">.queue.is_empty())
        </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.stopUpdater();
},

startUpdater: </span><span style="color:#0000FF;">function</span><span style="color:#000000;">() {
    </span><span style="color:#0000FF;">var</span><span style="color:#000000;"> _self </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">this</span><span style="color:#000000;">;
    </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (</span><span style="color:#0000FF;">this</span><span style="color:#000000;">.timer_id </span><span style="color:#000000;">==</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;">) {
        </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.timer_id </span><span style="color:#000000;">=</span><span style="color:#000000;"> setInterval(
            </span><span style="color:#0000FF;">function</span><span style="color:#000000;">() {
                </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (_self.running_task </span><span style="color:#000000;">==</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;">) {
                    </span><span style="color:#008000;">//</span><span style="color:#008000;"> We dont have any running task, lets make the first one</span><span style="color:#008000;">
</span><span style="color:#000000;">                    _self.running_task </span><span style="color:#000000;">=</span><span style="color:#000000;"> _self.queue.dq();
                    </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (_self.running_task </span><span style="color:#000000;">!=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;">) {
                        _self.ms_when_last_call_made </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> Date().getTime();
                        _self.running_task.code();
                    }
                }
                </span><span style="color:#0000FF;">else</span><span style="color:#000000;"> {
                    </span><span style="color:#008000;">//</span><span style="color:#008000;"> We have a running task already</span><span style="color:#008000;">
</span><span style="color:#000000;">                    _self.ms_elapsed_since_last_call </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> Date().getTime() </span><span style="color:#000000;">-</span><span style="color:#000000;"> _self.ms_when_last_call_made;

                    </span><span style="color:#008000;">//</span><span style="color:#008000;"> Should the current task be skipped?</span><span style="color:#008000;">
</span><span style="color:#000000;">                    </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (_self.ms_elapsed_since_last_call </span><span style="color:#000000;">&gt;</span><span style="color:#000000;"> _self.running_task.timeout)
                    </span><span style="color:#008000;">//</span><span style="color:#008000;"> Time's up. leave the task alone. Let other tasks start executing.</span><span style="color:#008000;">
</span><span style="color:#000000;">                        _self.detachTask(_self.running_task.id);
                }
            }, _self.interval);
    }
},

stopUpdater: </span><span style="color:#0000FF;">function</span><span style="color:#000000;">() {
    </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (</span><span style="color:#0000FF;">this</span><span style="color:#000000;">.timer_id </span><span style="color:#000000;">!=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;">) {
        clearInterval(</span><span style="color:#0000FF;">this</span><span style="color:#000000;">.timer_id)
        </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.timer_id </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;">;
    }

    </span><span style="color:#0000FF;">this</span><span style="color:#000000;">.queue </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> GenericQueue();
},</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Keep an eye on my blog for continued development and improvements, and download CallQueue from: <a href="http://code.msdn.microsoft.com/callqueue">http://code.msdn.microsoft.com/callqueue</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tanzimsaqib.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tanzimsaqib.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tanzimsaqib.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tanzimsaqib.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tanzimsaqib.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tanzimsaqib.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tanzimsaqib.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tanzimsaqib.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tanzimsaqib.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tanzimsaqib.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=101&subd=tanzimsaqib&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tanzimsaqib.wordpress.com/2008/11/19/callqueue-implementing-a-sequential-web-service-call-queue-for-ajax-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d65a9fc0993ccb92b3897422dbf28d84?s=96&#38;d=identicon" medium="image">
			<media:title type="html">tanzimsaqib</media:title>
		</media:content>
	</item>
		<item>
		<title>Cloudship: Membership Provider for the Cloud</title>
		<link>http://tanzimsaqib.wordpress.com/2008/11/14/cloudship-membership-provider-for-the-cloud/</link>
		<comments>http://tanzimsaqib.wordpress.com/2008/11/14/cloudship-membership-provider-for-the-cloud/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 05:03:53 +0000</pubDate>
		<dc:creator>tanzimsaqib</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Azure]]></category>

		<guid isPermaLink="false">http://tanzimsaqib.wordpress.com/2008/11/14/cloudship-membership-provider-for-the-cloud/</guid>
		<description><![CDATA[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’s cloud platform Windows Azure with no friction. Goals of this project [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=81&subd=tanzimsaqib&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>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’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().</p>
<p><a href="http://tanzimsaqib.files.wordpress.com/2008/11/azure-inheritance.png"><img style="border-width:0;" height="65" alt="azure_inheritance" src="http://tanzimsaqib.files.wordpress.com/2008/11/azure-inheritance-thumb.png?w=446&#038;h=65" width="446" border="0"></a> </p>
<p>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: </p>
<p>1. Reference the DLL<br />2. Insert few lines inside web.config<br />3. You are good to go
<p>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 – the future of development and business with Microsoft. Here you go &#8211; <a href="http://dotnetslackers.com/articles/aspnet/Azure-Cloudship-Membership-Provider-for-the-Cloud.aspx" target="_blank">Cloudship: Membership Provider for the Cloud</a>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tanzimsaqib.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tanzimsaqib.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tanzimsaqib.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tanzimsaqib.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tanzimsaqib.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tanzimsaqib.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tanzimsaqib.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tanzimsaqib.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tanzimsaqib.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tanzimsaqib.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=81&subd=tanzimsaqib&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tanzimsaqib.wordpress.com/2008/11/14/cloudship-membership-provider-for-the-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d65a9fc0993ccb92b3897422dbf28d84?s=96&#38;d=identicon" medium="image">
			<media:title type="html">tanzimsaqib</media:title>
		</media:content>

		<media:content url="http://tanzimsaqib.files.wordpress.com/2008/11/azure-inheritance-thumb.png" medium="image">
			<media:title type="html">azure_inheritance</media:title>
		</media:content>
	</item>
		<item>
		<title>Building applications for Windows Azure</title>
		<link>http://tanzimsaqib.wordpress.com/2008/11/07/building-applications-for-windows-azure/</link>
		<comments>http://tanzimsaqib.wordpress.com/2008/11/07/building-applications-for-windows-azure/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 09:14:39 +0000</pubDate>
		<dc:creator>tanzimsaqib</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Azure]]></category>

		<guid isPermaLink="false">http://tanzimsaqib.wordpress.com/2008/11/07/building-applications-for-windows-azure/</guid>
		<description><![CDATA[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&#8217;s Mosso or Amazon&#8217;s EC2, offer. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=78&subd=tanzimsaqib&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>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&#8217;s Mosso or Amazon&#8217;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&#8217;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.</p>
<p><a href="http://tanzimsaqib.files.wordpress.com/2008/11/azuretodolist.png"><img style="border-width:0;" height="402" alt="AzureTodolist" src="http://tanzimsaqib.files.wordpress.com/2008/11/azuretodolist-thumb.png?w=600&#038;h=402" width="600" border="0"></a> </p>
<p>I have written an article &#8220;<a href="http://dotnetslackers.com/articles/aspnet/Building-applications-for-Windows-Azure.aspx" target="_blank">Building applications for Windows Azure</a>&#8221; which will walk you through the steps to build an application from scratch on the recently released Windows Azure CTP, Microsoft’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.</p>
<p>Link: <a href="http://dotnetslackers.com/articles/aspnet/Building-applications-for-Windows-Azure.aspx">http://dotnetslackers.com/articles/aspnet/Building-applications-for-Windows-Azure.aspx</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tanzimsaqib.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tanzimsaqib.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tanzimsaqib.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tanzimsaqib.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tanzimsaqib.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tanzimsaqib.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tanzimsaqib.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tanzimsaqib.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tanzimsaqib.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tanzimsaqib.wordpress.com/78/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=78&subd=tanzimsaqib&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tanzimsaqib.wordpress.com/2008/11/07/building-applications-for-windows-azure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d65a9fc0993ccb92b3897422dbf28d84?s=96&#38;d=identicon" medium="image">
			<media:title type="html">tanzimsaqib</media:title>
		</media:content>

		<media:content url="http://tanzimsaqib.files.wordpress.com/2008/11/azuretodolist-thumb.png" medium="image">
			<media:title type="html">AzureTodolist</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery intellisense in Visual Studio</title>
		<link>http://tanzimsaqib.wordpress.com/2008/10/28/jquery-intellisense-in-visual-studio/</link>
		<comments>http://tanzimsaqib.wordpress.com/2008/10/28/jquery-intellisense-in-visual-studio/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 03:16:11 +0000</pubDate>
		<dc:creator>tanzimsaqib</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tanzimsaqib.wordpress.com/2008/10/28/jquery-intellisense-in-visual-studio/</guid>
		<description><![CDATA[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&#8217;t for it, here is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=71&subd=tanzimsaqib&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>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&#8217;t for it, here is the way how we can start developing using jQuery with full intellisense support inside Visual Studio 2008:</p>
<p>1. Download <a title="jquery-1.2.6-vsdoc.js" href="http://jqueryjs.googlecode.com/files/jquery-1.2.6-vsdoc.js">jquery-1.2.6-vsdoc.js</a></p>
<p>2. Inside your JavaScript files, add a reference to it by placing the following line at the top of the JavaScript file:</p>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:75bfd113-eb5b-4d43-924d-27184b451c01" style="display:inline;float:none;margin:0;padding:0;">
<pre style="background-color:White;overflow:auto;">
<div><span style="color:#008000;">//</span><span style="color:#008000;">/ &lt;reference path=&quot;jquery-1.2.6-vsdoc.js&quot; /&gt;</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>That&#8217;s it. Enjoy!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tanzimsaqib.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tanzimsaqib.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tanzimsaqib.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tanzimsaqib.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tanzimsaqib.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tanzimsaqib.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tanzimsaqib.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tanzimsaqib.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tanzimsaqib.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tanzimsaqib.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=71&subd=tanzimsaqib&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tanzimsaqib.wordpress.com/2008/10/28/jquery-intellisense-in-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d65a9fc0993ccb92b3897422dbf28d84?s=96&#38;d=identicon" medium="image">
			<media:title type="html">tanzimsaqib</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple Form Validation &#8211; A Reflection based approach</title>
		<link>http://tanzimsaqib.wordpress.com/2008/03/28/simple-form-validation-a-reflection-based-approach-2/</link>
		<comments>http://tanzimsaqib.wordpress.com/2008/03/28/simple-form-validation-a-reflection-based-approach-2/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 17:02:24 +0000</pubDate>
		<dc:creator>tanzimsaqib</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://tanzimsaqib.wordpress.com/2008/03/28/simple-form-validation-a-reflection-based-approach-2/</guid>
		<description><![CDATA[Are you tired of placing multiple Validation controls on Form? If you are bored of following scenario like me, keep on reading the post:
 
A simple Email address validation can consist of whether

The field is empty
Longer than limit
Email address format is invalid
Already in use

Ordinary solution to this problem is placing multiple validation controls for a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=70&subd=tanzimsaqib&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Are you tired of placing multiple Validation controls on Form? If you are bored of following scenario like me, keep on reading the post:</p>
<p><a href="http://tanzimsaqib.files.wordpress.com/2008/03/validators.png"><img style="border-width:0;" height="82" alt="Validators" src="http://tanzimsaqib.files.wordpress.com/2008/03/validators-thumb.png?w=365&#038;h=82" width="365" border="0"></a> </p>
<p>A simple Email address validation can consist of whether</p>
<ul>
<li>The field is empty
<li>Longer than limit
<li>Email address format is invalid
<li>Already in use</li>
</ul>
<p>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:</p>
<pre><span style="color:blue;">protected void </span>cvEmailAddress_ServerValidate(<span style="color:blue;">object </span>source, <span style="color:#2b91af;">ServerValidateEventArgs </span>args)
{
    <span style="color:#2b91af;">ValidationController</span>.ValidateControl&lt;<span style="color:#2b91af;">ProfileValidator</span>&gt;(cvEmailAddress, <span style="color:#2b91af;">ProfileValidator</span>.<span style="color:#2b91af;">Fields</span>.EmailAddress.ToString(), args);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Let us declare a ValidationErrorResult object that contains error messages and text to display in the UI:</p>
<pre><span style="color:blue;">public sealed class </span><span style="color:#2b91af;">ValidationErrorResult
</span>{
    <span style="color:blue;">public string </span>ErrorMessage { <span style="color:blue;">get</span>; <span style="color:blue;">set</span>; }
    <span style="color:blue;">public string </span>Text { <span style="color:blue;">get</span>; <span style="color:blue;">set</span>; }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>And an Attribute which would be used to tag a specific method which would be responsible for validation of particular control:</p>
<pre>[<span style="color:#2b91af;">AttributeUsage</span>(<span style="color:#2b91af;">AttributeTargets</span>.Method, Inherited = <span style="color:blue;">false</span>, AllowMultiple = <span style="color:blue;">true</span>)]
<span style="color:blue;">public sealed class </span><span style="color:#2b91af;">ValidationMethodAttribute </span>: <span style="color:#2b91af;">Attribute
</span>{
    <span style="color:blue;">public </span>ValidationMethodAttribute(<span style="color:blue;">string </span>fieldName)
    {
        <span style="color:blue;">this</span>.FieldName = fieldName;
    }

    <span style="color:blue;">public string </span>FieldName { <span style="color:blue;">get</span>; <span style="color:blue;">private set</span>; }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>If you are already familiar with Attirbute based programming, I hope you know the attribute of this piece of code is in fact <span style="color:#2b91af;">ValidationMethod</span>. We will soon see how to use this. The following is the method that checks the value and make a list of <span style="color:#2b91af;">ValidationErrorResult </span>that consists of which rules got failed. Notice that the <span style="color:#2b91af;">ValidationMethod</span> 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.</p>
<pre>[<span style="color:#2b91af;">ValidationMethod</span>(<span style="color:#a31515;">"Email"</span>)]
<span style="color:blue;">public static </span><span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">ValidationErrorResult</span>&gt; ValidateEmail(<span style="color:blue;">object </span>value)
{
    <span style="color:blue;">var </span>email = value <span style="color:blue;">as string</span>;
    <span style="color:blue;">var </span>results = <span style="color:blue;">new </span><span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">ValidationErrorResult</span>&gt;();

    <span style="color:green;">// Blank
    </span><span style="color:blue;">if </span>(<span style="color:blue;">string</span>.IsNullOrEmpty(email))
        results.Add(<span style="color:blue;">new </span><span style="color:#2b91af;">ValidationErrorResult</span>()
        {
            ErrorMessage = <span style="color:#a31515;">"You did not provide an Email Address."</span>,
            Text = <span style="color:#a31515;">"Cannot be left blank"
        </span>});

    <span style="color:green;">// Length 128
    </span><span style="color:blue;">if </span>(email.Length &gt; 128)
        results.Add(<span style="color:blue;">new </span><span style="color:#2b91af;">ValidationErrorResult</span>()
        {
            ErrorMessage = <span style="color:#a31515;">"You exceeded length limit."</span>,
            Text = <span style="color:#a31515;">"Keep it less than 129 characters"
        </span>});

    <span style="color:green;">// Valid Email Address
    </span><span style="color:blue;">if </span>(!<span style="color:#2b91af;">Regex</span>.IsMatch(email, <span style="color:#a31515;">"^[\\w\\.\\-]+@[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]{1,})*(\\.[a-zA-Z]{2,3}){1,2}$"</span>))
        results.Add(<span style="color:blue;">new </span><span style="color:#2b91af;">ValidationErrorResult</span>()
        {
            ErrorMessage = <span style="color:#a31515;">"You provided an invalid Email Address."</span>,
            Text = <span style="color:#a31515;">"Invalid Email Address"
        </span>});

    <span style="color:green;">// Is Already In Use
    </span><span style="color:blue;">if </span>(IsAlreadyInUse(email))
        results.Add(<span style="color:blue;">new </span><span style="color:#2b91af;">ValidationErrorResult</span>()
        {
            ErrorMessage = <span style="color:#a31515;">"You provided an invalid Email Address."</span>,
            Text = <span style="color:#a31515;">"Invalid Email Address"
        </span>});

    <span style="color:blue;">return </span>results;
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Here is the ValidationController which goes through the Validation class and looks for the method that has the attribute which validates the control&#8217;s value.</p>
<pre><span style="color:blue;">public class </span><span style="color:#2b91af;">ValidationController
</span>{
    <span style="color:blue;">public static </span><span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">ValidationErrorResult</span>&gt; Validate&lt;T&gt;(<span style="color:blue;">string </span>fieldName, <span style="color:blue;">object </span>value)
    {
        <span style="color:blue;">var </span>results = <span style="color:blue;">new </span><span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">ValidationErrorResult</span>&gt;();
        <span style="color:blue;">var </span>type = <span style="color:blue;">typeof</span>(T);
        <span style="color:blue;">var </span>methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public);

        <span style="color:blue;">var </span>method = methods.Single&lt;MethodInfo&gt;(<span style="color:blue;">delegate</span>(MethodInfo m)
        {
            <span style="color:blue;">return </span>((<span style="color:#2b91af;">ValidationMethodAttribute</span>[])m.GetCustomAttributes(<span style="color:blue;">typeof</span>(<span style="color:#2b91af;">ValidationMethodAttribute</span>), <span style="color:blue;">false</span>))[0].FieldName == fieldName;
        });

        <span style="color:blue;">return </span>(<span style="color:#2b91af;">List</span>&lt;<span style="color:#2b91af;">ValidationErrorResult</span>&gt;)method.Invoke(<span style="color:blue;">null</span>, <span style="color:blue;">new object</span>[] { value });
    }

    <span style="color:blue;">public static void </span>ValidateControl&lt;T&gt;(<span style="color:#2b91af;">CustomValidator </span>validator, <span style="color:blue;">string </span>fieldName, <span style="color:#2b91af;">ServerValidateEventArgs </span>args)
    {
        <span style="color:blue;">var </span>results = Validate&lt;T&gt;(fieldName, args.Value);

        <span style="color:blue;">if </span>(!(args.IsValid = !(results.Count &gt; 0)))
        {
            validator.ErrorMessage = results[0].ErrorMessage;
            validator.Text = results[0].Text;
        }
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tanzimsaqib.wordpress.com/70/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tanzimsaqib.wordpress.com/70/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tanzimsaqib.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tanzimsaqib.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tanzimsaqib.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tanzimsaqib.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tanzimsaqib.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tanzimsaqib.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tanzimsaqib.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tanzimsaqib.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tanzimsaqib.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tanzimsaqib.wordpress.com/70/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=70&subd=tanzimsaqib&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tanzimsaqib.wordpress.com/2008/03/28/simple-form-validation-a-reflection-based-approach-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d65a9fc0993ccb92b3897422dbf28d84?s=96&#38;d=identicon" medium="image">
			<media:title type="html">tanzimsaqib</media:title>
		</media:content>

		<media:content url="http://tanzimsaqib.files.wordpress.com/2008/03/validators-thumb.png" medium="image">
			<media:title type="html">Validators</media:title>
		</media:content>
	</item>
		<item>
		<title>[New Article] 7 ways to do Performance Optimization of an ASP.NET 3.5 Web 2.0 portal</title>
		<link>http://tanzimsaqib.wordpress.com/2008/02/05/new-article-7-ways-to-do-performance-optimization-of-an-aspnet-35-web-20-portal/</link>
		<comments>http://tanzimsaqib.wordpress.com/2008/02/05/new-article-7-ways-to-do-performance-optimization-of-an-aspnet-35-web-20-portal/#comments</comments>
		<pubDate>Tue, 05 Feb 2008 05:31:00 +0000</pubDate>
		<dc:creator>tanzimsaqib</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://tanzimsaqib.wordpress.com/2008/02/05/new-article-7-ways-to-do-performance-optimization-of-an-aspnet-35-web-20-portal/</guid>
		<description><![CDATA[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 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=58&subd=tanzimsaqib&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>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.</p>
<p>Performance is a vast area and great results can never be achieved by a silver bullet. <a href="http://dotnetslackers.com/articles/aspnet/SevenWaysToDoPerformanceOptimizationOfAnASPNET35Web20Portal.aspx" target="_blank">This article</a> 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. </p>
<p>URL: <a title="http://dotnetslackers.com/articles/aspnet/SevenWaysToDoPerformanceOptimizationOfAnASPNET35Web20Portal.aspx" href="http://dotnetslackers.com/articles/aspnet/SevenWaysToDoPerformanceOptimizationOfAnASPNET35Web20Portal.aspx">http://dotnetslackers.com/articles/aspnet/SevenWaysToDoPerformanceOptimizationOfAnASPNET35Web20Portal.aspx</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tanzimsaqib.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tanzimsaqib.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tanzimsaqib.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tanzimsaqib.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tanzimsaqib.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tanzimsaqib.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tanzimsaqib.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tanzimsaqib.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tanzimsaqib.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tanzimsaqib.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tanzimsaqib.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tanzimsaqib.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tanzimsaqib.wordpress.com&blog=1242602&post=58&subd=tanzimsaqib&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tanzimsaqib.wordpress.com/2008/02/05/new-article-7-ways-to-do-performance-optimization-of-an-aspnet-35-web-20-portal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d65a9fc0993ccb92b3897422dbf28d84?s=96&#38;d=identicon" medium="image">
			<media:title type="html">tanzimsaqib</media:title>
		</media:content>
	</item>
	</channel>
</rss>