<?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>Me Myself &#38; C#</title>
	<atom:link href="http://gargmanoj.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gargmanoj.wordpress.com</link>
	<description>Manoj Garg's Tech Bytes - What I learned Today</description>
	<lastBuildDate>Wed, 25 Nov 2009 13:14:16 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='gargmanoj.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/ef5fb8d61583d64951ce173271967f38?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Me Myself &#38; C#</title>
		<link>http://gargmanoj.wordpress.com</link>
	</image>
			<item>
		<title>DOM property comparison for different browsers: What Works Where?</title>
		<link>http://gargmanoj.wordpress.com/2009/11/25/dom-property-comparison-for-different-browsers-what-works-where/</link>
		<comments>http://gargmanoj.wordpress.com/2009/11/25/dom-property-comparison-for-different-browsers-what-works-where/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 13:09:46 +0000</pubDate>
		<dc:creator>Manoj Garg</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[browser compatibility]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[innerText]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[textContent]]></category>

		<guid isPermaLink="false">http://gargmanoj.wordpress.com/2009/11/25/dom-property-comparison-for-different-browsers-what-works-where/</guid>
		<description><![CDATA[Today, I was working on a UI enhancement task where I had to do some DOM manipulation. Basically task was changing color of some SPAN elements in DOM depending on their value like if it&#8217;s value is XXX then show in RED color and so on. As always I was using IE to test my [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=199&subd=gargmanoj&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Today, I was working on a UI enhancement task where I had to do some DOM manipulation. Basically task was changing color of some SPAN elements in DOM depending on their value like if it&#8217;s value is XXX then show in RED color and so on. As always I was using IE to test my Java script code written to do the job. In JS code, I used &#8220;innerText&#8221; property of SPAN element to get the text of that element and then did the comparison to change the color and It worked fine. When I ran same JS code on Mozilla, it didn&#8217;t run (I mean it got executed but didn&#8217;t changed color of SPAN elements to RED <span style="font-family:Wingdings;">L</span>) . On debugging the script, I was surprised to see value of <em>innerText</em> property being returned <strong><em>null</em></strong>. When googled around it and found that only Mozilla doesn&#8217;t support this property <span style="font-family:Wingdings;">L</span>. Mozilla has another property &#8220;textContent&#8221; which has same value as innerText in other browsers.
</p>
<p>Solution was simple, use an ORing of both the values instead of putting if-else block in code to use <em>textContent</em> if the user is running Mozilla or innerText for any other browser.
</p>
<p>var txtName = clientNameElement.innerText || clientNameElement.textContent;
</p>
<p>I picked up this solution from <a href="http://www.quirksmode.org/dom/w3c_html.html">here</a>. This link provides a good comparison of various DOM properties on different browsers that is what works and what not <span style="font-family:Wingdings;">J</span>.
</p>
<p>Hope it helps some of you while writing code to cater to multiple browsers <span style="font-family:Wingdings;">J</span>
	</p>
Posted in JavaScript Tagged: browser compatibility, DOM, IE, innerText, Mozilla, textContent <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gargmanoj.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gargmanoj.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gargmanoj.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gargmanoj.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gargmanoj.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gargmanoj.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gargmanoj.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gargmanoj.wordpress.com/199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gargmanoj.wordpress.com/199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gargmanoj.wordpress.com/199/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=199&subd=gargmanoj&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gargmanoj.wordpress.com/2009/11/25/dom-property-comparison-for-different-browsers-what-works-where/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/573160ada16637cc5630116b72fd98de?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gargmanoj</media:title>
		</media:content>
	</item>
		<item>
		<title>Blogging right from Word 2007</title>
		<link>http://gargmanoj.wordpress.com/2009/09/22/blogging-right-from-word-2007/</link>
		<comments>http://gargmanoj.wordpress.com/2009/09/22/blogging-right-from-word-2007/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 11:24:35 +0000</pubDate>
		<dc:creator>Manoj Garg</dc:creator>
				<category><![CDATA[Microsoft Word 2007]]></category>
		<category><![CDATA[Non Technical]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[blogging from word 2007]]></category>
		<category><![CDATA[office 2007]]></category>

		<guid isPermaLink="false">http://gargmanoj.wordpress.com/?p=178</guid>
		<description><![CDATA[I have been using Microsoft Office 2007 since last one and half years and frankly speaking &#8220;I&#8217;m lovin&#8217; it&#8221;. Be it quick style feature of Word 2007 or ShapeStyle, WordArt Style of Powerpoint 2007, I have been using them extensively in this period. The new interface is so usable at the same time providing me [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=178&subd=gargmanoj&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">I have been using Microsoft Office 2007 since last one and half years and frankly speaking &#8220;I&#8217;m lovin&#8217; it&#8221;. Be it quick style feature of Word 2007 or ShapeStyle, WordArt Style of Powerpoint 2007, I have been using them extensively in this period. The new interface is so usable at the same time providing me lots of, out of the box available formatting features like table style, document templates n so on.
</p>
<p style="text-align:justify;">Ok so enough of praises for Office 2007, after all this post is not about why I like it. There are plethora of resources, posts, videos available over net describing the above mention benefits (features) of office 2007.  This post is about creating and publishing a blog entry right from Word 2007 document. Since last few days I have been trying to be little active with my blog and write something to do justice with the its tagline &#8220;<strong><em>What I learned today</em></strong>&#8220;. Last week I was reading <a href="http://phapalegaurav.blogspot.com/2009/09/test-post.html">Gaurav&#8217;s blog</a> and there he had a post about blogging from Word itself. So far I have been using Windows Live Writer to do most of my blogging related stuff(which is minimal BTW <span style="font-family:Wingdings;">J</span>), which is a great tool for blogging but it didn&#8217;t allowed me to format my post the way I wanted them to for ex putting quotes, creating colored tables for comparison related stuff etc. After reading gaurav&#8217;s post, I myself thought to give a spin to this feature of publishing content from word.
</p>
<p style="text-align:justify;">So here is the post for my tryst with blogging in Word 2007.
</p>
<h2>Enable publishing form word<br />
</h2>
<p>
 </p>
<div>
<table style="border-collapse:collapse;" border="0">
<col>
<col>
<tbody valign="top">
<tr>
<td style="padding-left:7px;padding-right:7px;">
<p style="text-align:justify;"><img src="http://gargmanoj.files.wordpress.com/2009/09/092209_1123_bloggingrig11.png"></p>
</td>
<td style="padding-left:7px;padding-right:7px;">
<p style="text-align:justify;">Go to Office Button in word and then select Blog option for Publish menu item.
</p>
<p style="text-align:justify;">This would ask you to register a blog account with MS Word. Register your blog by providing the details about your blog as shown in below screenshots.
</p>
<p style="text-align:justify;">
 </p>
<p style="text-align:justify;"><img src="http://gargmanoj.files.wordpress.com/2009/09/092209_1123_bloggingrig21.png">
						</p>
<p style="text-align:justify;">
 </p>
<p style="text-align:justify;"><img src="http://gargmanoj.files.wordpress.com/2009/09/092209_1123_bloggingrig31.png">
						</p>
<p style="text-align:justify;">
 </p>
<p style="text-align:justify;"><img src="http://gargmanoj.files.wordpress.com/2009/09/092209_1123_bloggingrig41.png">
						</p>
</td>
</tr>
</tbody>
</table>
</div>
<p style="text-align:justify;">
 </p>
<p style="text-align:justify;">After registering the blog a new word document will open and you are good to go. I tried various formatting setting, picture formatting. So far so good. I am going to use word now instead of Livewriter.</p>
Posted in Microsoft Word 2007, Non Technical Tagged: blog, blogging from word 2007, office 2007 <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gargmanoj.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gargmanoj.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gargmanoj.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gargmanoj.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gargmanoj.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gargmanoj.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gargmanoj.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gargmanoj.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gargmanoj.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gargmanoj.wordpress.com/178/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=178&subd=gargmanoj&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gargmanoj.wordpress.com/2009/09/22/blogging-right-from-word-2007/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/573160ada16637cc5630116b72fd98de?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gargmanoj</media:title>
		</media:content>

		<media:content url="http://gargmanoj.files.wordpress.com/2009/09/092209_1123_bloggingrig11.png" medium="image" />

		<media:content url="http://gargmanoj.files.wordpress.com/2009/09/092209_1123_bloggingrig21.png" medium="image" />

		<media:content url="http://gargmanoj.files.wordpress.com/2009/09/092209_1123_bloggingrig31.png" medium="image" />

		<media:content url="http://gargmanoj.files.wordpress.com/2009/09/092209_1123_bloggingrig41.png" medium="image" />
	</item>
		<item>
		<title>ViewState Compression in ASP.NET 2.0</title>
		<link>http://gargmanoj.wordpress.com/2009/09/16/viewstate-compression-in-asp-net-2-0/</link>
		<comments>http://gargmanoj.wordpress.com/2009/09/16/viewstate-compression-in-asp-net-2-0/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 15:26:10 +0000</pubDate>
		<dc:creator>Manoj Garg</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ViewState]]></category>
		<category><![CDATA[.browser]]></category>
		<category><![CDATA[ControlState]]></category>
		<category><![CDATA[IIS compression]]></category>
		<category><![CDATA[LoadPageStateFromPersistenceMedium]]></category>
		<category><![CDATA[PageAdapter]]></category>
		<category><![CDATA[PageStatePersister]]></category>
		<category><![CDATA[RequiresControlStateInSession]]></category>
		<category><![CDATA[SavePageStateToPersistenceMedium]]></category>
		<category><![CDATA[Session]]></category>
		<category><![CDATA[Viewstate compression]]></category>

		<guid isPermaLink="false">http://gargmanoj.wordpress.com/?p=161</guid>
		<description><![CDATA[&#34;STATE as a noun can be described as &#34;the condition of a person or thing, as with respect to circumstances or attributes&#34;.&#160; In ASP.NET world, State of a control or a page is what it looks like, what its value is and what its value was before the page was posted back.&#34;

Since HTTP is stateless, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=161&subd=gargmanoj&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><blockquote><p align="justify"><font size="3"><font face="Calibri"><span style="font-size:large;">&quot;</span><span style="font-family:georgia;font-size:small;">STATE as a noun can be described as &quot;<em>the condition of a person or thing, as with respect to circumstances or attributes</em>&quot;.&#160; In ASP.NET world, State of a control or a page is what it looks like, what its value is and what its value was before the page was posted back</span>.<span style="font-size:large;">&quot;</span></font></font></p>
</blockquote>
<p align="justify"><span style="font-family:georgia;font-size:x-small;"><font size="3">Since HTTP is stateless, to maintain state across postbacks in ASP.NET, some state management techniques are used. In ASP.NET state management can be categorized in two types depending on the location where state is being kept:</font></span></p>
<ol>
<li>
<div align="justify"><span style="font-size:x-small;"><span style="font-family:georgia;"><font face="Cambria Math"><font size="3"><strong>Client Side</strong>: <font face="Georgia">Client side state management involves keeping the state data on the client end, either on client machine or the browser. There are various mechanisms to maintain state on client side like<em> Cookies, ViewState, Hidden Fields, Control State, Query strings</em> etc.</font> </font></font></span></span></div>
</li>
<li>
<div align="justify"><span style="font-family:ge;"><span style="font-size:x-small;"><font size="3"><font face="Cambria Math"><span style="font-family:georgia;"><strong>Server Side</strong>: Server side management is keeping state on a different machine be it database or file system on a different computer. Server side state management can be done using Application State, Session state etc. this data can be&#160; stored in the server process or in a database or server file system.</span> </font></font></span></span></div>
</li>
</ol>
<p align="justify"><span style="font-family:georgia;font-size:x-small;"><font size="3">For detailed information about different option available for state management in ASP.NET, please refer </font></span><a href="http://msdn.microsoft.com/en-us/library/75x4ha6s(printer).aspx" target="_blank"><span style="font-family:georgia;font-size:x-small;"><font size="3">this</font></span></a><span style="font-family:georgia;font-size:x-small;"><font size="3"> link for MSDN. </font></span><a href="http://www.dotnetfunda.com/articles/article61.aspx" target="_blank"><span style="font-family:georgia;font-size:x-small;"><font size="3">This </font></span></a><span style="font-family:georgia;font-size:x-small;"><font size="3">link also gives a good comparison of various state management techniques with&#160; their pros n cons.</font></span></p>
<p align="justify"><span style="font-family:georgia;font-size:x-small;"><font size="3">ViewState is the first thing that come to mind when dealing with postbacks in ASP.NET.</font></span></p>
<h2>ViewState</h2>
<p align="justify"><span style="font-family:georgia;font-size:x-small;"><font size="3">In simple terms, ViewState is keeping information about page in a non-readable i.e. serialized way with the page itself. In ASP.NET, view state is kept in a hidden field name _VIEWSTATE on the page. So every time the page loads after the postback this serialized data is read and appropriate state is loaded into the controls.</font></span></p>
<p align="justify"><span style="font-family:georgia;font-size:x-small;"><font size="3">To understand how viewstate is saved and loaded, one should know the page life cycle i.e. the steps a request, for loading a page, goes through before a page is fully rendered into the browser. </font></span><a href="http://msdn.microsoft.com/en-us/library/ms972976(printer).aspx" target="_blank"><span style="font-family:georgia;font-size:x-small;"><font size="3">This </font></span></a><span style="font-family:georgia;font-size:x-small;"><font size="3">link on MSDN explains Page life cycle along with a good overview of what view state is.&#160; </font><a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx" target="_blank"><font size="3">This</font></a><font size="3"> post by <em>Dave Reed</em> gets under the hood of view state and explains the nuances of view state very well. I would recommend reading the above mention post to every one. That post has been the best link I have come across on view state.</font></span></p>
<p align="justify"><span style="font-family:georgia;font-size:x-small;"><font size="3">As mentioned above, View state is kept in a hidden field _VIEWSTATE on the page. So every time the page is posted back to the server or retrieved from server, the content of View state also travel along with page content. In turn contributing to usage of network resources. Generally, developers have tendency to keep view state enabled for controls on their page. which unknowingly keeps growing the page size. This means as page size grows, it would take longer for the page to completely render itself. </font></span></p>
<p align="justify"><span style="font-family:georgia;font-size:x-small;"><font size="3">Problem comes when the page size grows inordinately and waiting time for the end user to see the completely rendered page is too high. There are recommendation that one should use viewstate as minimally as possible to ensure the page size is with in limits. But sometime scenario enforces the developer to use viewstate in his/her page. In such cases following are some of the guideline/approaches to keep view state size in check.</font></span></p>
<ol>
<li>
<div align="justify"><span style="font-family:georgia;font-size:x-small;"><font size="3"><strong>Enable view state for a control only when absolutely necessary</strong>: Set the EnableViewState attribute for the control to <em>false</em> explicitly, when you are sure that you do not require to keep state for that control.</font></span></div>
</li>
<li>
<div align="justify"><span style="font-family:georgia;font-size:x-small;"><font size="3"><strong>Don’t save large datasets into view state</strong>: Whenever possible keep the datasets and big data tables in cache or say session so that view state is small.</font></span></div>
</li>
<li>
<div align="justify"><span style="font-size:x-small;"><span style="font-family:georgia;"><font size="3"><strong>Use IIS Compression</strong>: Internet Information Services(IIS) has the feature to provide compression for the pages it serves as response to the requests received. You can configure the IIS on your server to compress the appropriate websites or pages in the website. For detailed information about how to configure the IIS configuration on your server, please read </font></span></span><a href="http://weblogs.asp.net/owscott/archive/2004/01/12/57916.aspx" target="_blank"><span style="font-family:georgia;font-size:x-small;"><font size="3">this</font></span></a><span style="font-family:georgia;"><font size="3"><span style="font-size:x-small;"> <font size="3">post by </font></span><span style="font-size:x-small;"><font size="3"><em>Scott Forsyth</em>.&#160; There is one another </font><a href="http://www.codeproject.com/KB/dotnet/DotNetBestPractices4.aspx" target="_blank"><font size="3">post</font></a><font size="3"> by <em>Shivprasad koirala</em>, which is an extension of the post by <em>Scott Forsyth</em>, it also explains IIS compression in great details along with it also provides some comparison statistics data about what level of compression is good and for what type of pages one should avail this</font> </span></font></span></div>
</li>
<li>
<div align="justify"><span style="font-family:georgia;font-size:x-small;"><font size="3"><strong>Using old ASP.NET 1.1 approach for storing the view state on server</strong>: In Page life cycle there are two steps available which do the job of fetching the view state from the hidden field and putting the view state content back into the hidden field it was stored. These methods are </font><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.loadpagestatefrompersistencemedium.aspx" target="_blank"><font size="3">LoadPageStateFromPersistenceMedium</font></a><em></em><font size="3"> and <em><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.savepagestatetopersistencemedium.aspx" target="_blank">SavePageStateToPersistenceMedium</a>. </em>These methods are virtual methods from the Page class. A simplest approach would be to store the viewstate in session itself. Following code snippet shows how this could be done by overriding the two above mentioned methods and storing the viewstate in session after serializing and loading the viewstate from session again after desterilizing it. Serialization and deserialization is done using </font><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.losformatter.aspx" target="_blank"><font size="3">LosFormatter</font></a><font size="3"> class. One can use any of the available formatters, </font><a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx" target="_blank"><font size="3">BinaryFormatter</font></a><font size="3">, </font><a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.soap.soapformatter.aspx" target="_blank"><font size="3">SOAPFormatter</font></a><font size="3"> etc., for serializing the viewstate content. Content is stored in session with SessionID being the key.</font></span></div>
</li>
</ol>
<div style="border-bottom:#cecece 1pt solid;border-left:#cecece 1pt solid;background:#fbfbfb;margin-left:.5in;border-top:#cecece 1pt solid;margin-right:0;border-right:#cecece 1pt solid;padding:4pt;">
<pre style="border-bottom:medium none;border-left:medium none;background:#fbfbfb;border-top:medium none;border-right:medium none;padding:0;"><font size="2"><span style="color:blue;" lang="EN">protected</span><span lang="EN"> <span style="color:blue;">override</span> <span style="color:blue;">object</span> LoadPageStateFromPersistenceMedium ()</span></font></pre>
<pre style="border-bottom:medium none;border-left:medium none;background:#fbfbfb;border-top:medium none;border-right:medium none;padding:0;"><span lang="EN"><font size="2">{</font></span></pre>
<pre style="border-bottom:medium none;border-left:medium none;background:#fbfbfb;border-top:medium none;border-right:medium none;padding:0;"><span lang="EN"></span><span lang="EN"><font size="2"><span>&#160;&#160;&#160; </span><span style="color:blue;">return</span> (<span style="color:blue;">new</span> LosFormatter().Deserialize ((<span style="color:blue;">string</span>)Session[Session.SessionID]));</font></span></pre>
<pre style="border-bottom:medium none;border-left:medium none;background:#fbfbfb;border-top:medium none;border-right:medium none;padding:0;"><span lang="EN"><font size="2">}
</font></span><font size="2"><span style="color:blue;" lang="EN">protected</span><span lang="EN"> <span style="color:blue;">override</span> <span style="color:blue;">void</span> SavePageStateToPersistenceMedium (<span style="color:blue;">object</span> state)</span></font></pre>
<pre style="border-bottom:medium none;border-left:medium none;background:#fbfbfb;border-top:medium none;border-right:medium none;padding:0;"><span lang="EN"><font size="2">{</font></span></pre>
<pre style="border-bottom:medium none;border-left:medium none;background:#fbfbfb;border-top:medium none;border-right:medium none;padding:0;"><span lang="EN"><font size="2"><span>&#160;&#160;&#160; </span>LosFormatter los = <span style="color:blue;">new</span> LosFormatter();</font></span></pre>
<pre style="border-bottom:medium none;border-left:medium none;background:#fbfbfb;border-top:medium none;border-right:medium none;padding:0;"><span lang="EN"><font size="2"><span>&#160;&#160;&#160; </span>los.Serialize (sw, state);</font></span></pre>
<pre style="border-bottom:medium none;border-left:medium none;background:#fbfbfb;border-top:medium none;border-right:medium none;padding:0;"><span lang="EN"><font size="2"><span>&#160;&#160;&#160; </span><span style="color:blue;">string</span> vs = sw.ToString ();</font></span></pre>
<pre style="border-bottom:medium none;border-left:medium none;background:#fbfbfb;border-top:medium none;border-right:medium none;padding:0;"><span lang="EN"><font size="2"><span>&#160;&#160;&#160; </span>Session[Session.SessionID] = vs;</font></span></pre>
<pre style="border-bottom:medium none;border-left:medium none;background:#fbfbfb;border-top:medium none;border-right:medium none;padding:0;"><span lang="EN"><font size="2">}</font></span></pre>
</div>
<p align="justify"><font size="3" face="Cambria Math"></font></p>
<p align="justify"><font size="3" face="Georgia">An improvement in above mentioned approach could be to apply the compression on the viewstate content before storing them in session and decompressing the session content before restoring the viewstate. Following code does exactly this. This code introduces one more step, between storing and retrieving the view state from session, by compressing and decompressing the content. This approach again leads to save some more bandwidth.</font></p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;color:blue;font-size:10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; protected</span><span style="font-family:&#39;font-size:10pt;"> <span style="color:blue;">override</span> <span style="color:blue;">object</span> LoadPageStateFromPersistenceMedium() </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">string</span> viewState = (<span style="color:blue;">string</span>)Session[Session.SessionID]; </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">byte</span>[] bytes = <span style="color:#2b91af;">Convert</span>.FromBase64String(viewState); </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>bytes = Compressor.Decompress(bytes); </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>LosFormatter formatter = <span style="color:blue;">new</span> LosFormatter(); </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">return</span> formatter.Deserialize(<span style="color:#2b91af;">Convert</span>.ToBase64String(bytes)); </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">protected</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> SavePageStateToPersistenceMedium(<span style="color:blue;">object</span> state) </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>LosFormatter formatter = <span style="color:blue;">new</span> LosFormatter(); </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:#2b91af;">StringWriter</span> writer = <span style="color:blue;">new</span> <span style="color:#2b91af;">StringWriter</span>(); </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>formatter.Serialize(writer, state); </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">string</span> viewStateString = writer.ToString(); </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">byte</span>[] bytes = <span style="color:#2b91af;">Convert</span>.FromBase64String(viewStateString); </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>bytes = Compressor.Compress(bytes); </span></p>
</p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Session[Session.SessionID] = <span style="color:#2b91af;">Convert</span>.ToBase64String(bytes);</span></p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</span></p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>&#160;&#160; 5. <font size="3" face="Cambria Math"><strong>ASP.NET 2.0 approach for saving viewstate on server:</strong></font> </p>
<p align="justify"><font size="3" face="Georgia">In ASP.NET 2.0, ViewState is saved by a descendant of </font><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.pagestatepersister.aspx" target="_blank"><em><font size="3" face="Georgia">PageStatePersister</font></em></a><font size="3" face="Georgia"> class. This class is an abstract class for saving and loading ViewsState and there are two implemented descendants of this class in .Net Framework, named </font><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.hiddenfieldpagestatepersister.aspx" target="_blank"><em><font size="3" face="Georgia">HiddenFieldPageStatePersister</font></em></a><font size="3" face="Georgia"> and </font><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.sessionpagestatepersister.aspx" target="_blank"><em><font size="3" face="Georgia">SessionPageStatePersister</font></em></a><font size="3" face="Georgia">. By default <em>HiddenFieldPageStatePersister</em> is used to save/load ViewState information, but we can easily get the <em>SessionPageStatePersister</em> to work and save ViewState in Session object. The only thing to do this is to override </font><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.pagestatepersister.aspx" target="_blank"><em><font size="3" face="Georgia">PageStatePersister</font></em></a><font size="3" face="Georgia"> property of <em>Page</em> class and ask it to return an instance of <em>SessionPageStatePersister</em> class:</font></p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;color:blue;font-size:12pt;">protected</span><span style="font-family:&#39;font-size:12pt;"> <span style="color:blue;">override</span> <span style="color:teal;">PageStatePersister</span> PageStatePersister </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:12pt;">{ </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:12pt;"><span>&#160;&#160;&#160; </span><span style="color:blue;">get </span></p>
<p>  </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:12pt;"><span>&#160;&#160;&#160; </span>{ </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:12pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">return</span> <span style="color:blue;">new</span> <span style="color:teal;">SessionPageStatePersister</span>(Page); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:12pt;"><span>&#160;&#160;&#160; </span>} </span></p>
</p>
<p style="margin:0 0 10pt;" class="MsoNormal"><span style="line-height:115%;font-family:&#39;font-size:12pt;">}</span><span style="line-height:115%;font-size:12pt;"> </span></p>
</p>
<p align="justify"><font size="3" face="Georgia">The <em>PageStatePersister</em> class can be inherited to also created custom storage mediums for session state. The <em>PageStatePersister</em> class has two methods <i>Load()</i> and <i>Save()</i> which can be used to provide custom loading and saving media for ViewState.</font></p>
<p style="text-align:justify;line-height:18pt;margin:.2in 0;"><span style="font-family:&#39;color:blue;font-size:10pt;">public</span><span style="font-family:&#39;font-size:10pt;"> <span style="color:blue;">class</span> <span style="color:teal;">StreamPageStatePersister</span> : <span style="color:teal;">PageStatePersister </span></p>
<p>  </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160; </span>{ </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>&#160;</p>
<p>  <span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">public</span> StreamPageStatePersister(<span style="color:teal;">Page</span> page) </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>: <span style="color:blue;">base</span>(page) </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;color:blue;font-size:10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; public</span><span style="font-family:&#39;font-size:10pt;"> <span style="color:blue;">override</span> <span style="color:blue;">void</span> Load() </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span>&#160;&#160;&#160; </span>{ </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:teal;">Stream</span> stateStream = GetSecureStream(); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>  <span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:green;">// Read the state string, using the StateFormatter. </span></p>
<p>  </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:teal;">StreamReader</span> reader = <span style="color:blue;">new</span> <span style="color:teal;">StreamReader</span>(stateStream); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>  <span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:teal;">IStateFormatter</span> formatter = <span style="color:blue;">this</span>.StateFormatter; </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">string</span> fileContents = reader.ReadToEnd(); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>  <span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:green;">// Deserilize returns the Pair object that is serialized in </span></p>
<p>  </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:green;">// the Save method. </span></p>
<p>  </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:teal;">Pair</span> statePair = (<span style="color:teal;">Pair</span>)formatter.Deserialize(fileContents); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>  <span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>ViewState = statePair.First; </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>ControlState = statePair.Second; </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>reader.Close(); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>stateStream.Close(); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span>&#160;&#160;&#160; </span>} </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:green;"></span></p>
<p>  </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">public</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> Save() </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>&#160;</p>
<p>  <span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">if</span> (ViewState != <span style="color:blue;">null</span> || ControlState != <span style="color:blue;">null</span>) </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">if</span> (Page.Session != <span style="color:blue;">null</span>) </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:teal;">Stream</span> stateStream = GetSecureStream(); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>&#160;</p>
<p>  <span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:teal;">StreamWriter</span> writer = <span style="color:blue;">new</span> <span style="color:teal;">StreamWriter</span>(stateStream); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>&#160;</p>
<p>  <span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:teal;">IStateFormatter</span> formatter = <span style="color:blue;">this</span>.StateFormatter; </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:teal;">Pair</span> statePair = <span style="color:blue;">new</span> <span style="color:teal;">Pair</span>(ViewState, ControlState); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>&#160;</p>
<p>  <span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:green;">// Serialize the statePair object to a string. </span></p>
<p>  </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">string</span> serializedState = formatter.Serialize(statePair); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"></span></p>
<p>&#160;</p>
<p>  <span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>writer.Write(serializedState); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>writer.Close(); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>stateStream.Close(); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">else </span></p>
<p>  </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">throw</span> <span style="color:blue;">new</span> <span style="color:teal;">InvalidOperationException</span>(&quot;Session needed for StreamPageStatePersister.&quot;); </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span></p>
</p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span></p>
</p>
<p style="margin:0 0 10pt;" class="MsoNormal"><span style="line-height:115%;font-family:&#39;font-size:10pt;"><span>&#160;&#160;&#160; </span>}</span><span style="font-family:&#39;color:#4f81bd;"> </span></p>
</p>
<p><font size="3" face="Georgia">Then a </font><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.adapters.pageadapter.aspx" target="_blank"><font size="3" face="Georgia">PageAdapter</font></a><font size="3" face="Georgia"> can be used to use this persister</font> </p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;color:blue;font-size:10pt;">public</span><span style="font-family:&#39;color:black;font-size:10pt;"> </span><span style="font-family:&#39;color:blue;font-size:10pt;">class</span><span style="font-family:&#39;color:black;font-size:10pt;"> MyPageAdapter : System.Web.UI.Adapters.PageAdapter </p>
<p>  </span></p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;color:black;font-size:10pt;">{</p>
<p>  </span></p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;color:black;font-size:10pt;"><span>&#160;&#160;&#160; </span></span><span style="font-family:&#39;color:blue;font-size:10pt;">public</span><span style="font-family:&#39;color:black;font-size:10pt;"> override PageStatePersister GetStatePersister() {</p>
<p>  </span></p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;color:black;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family:&#39;color:blue;font-size:10pt;">return</span><span style="font-family:&#39;color:black;font-size:10pt;"> </span><span style="font-family:&#39;color:blue;font-size:10pt;">new</span><span style="font-family:&#39;color:black;font-size:10pt;"> Samples.AspNet.CS.StreamPageStatePersister(Page);</p>
<p>  </span></p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;color:black;font-size:10pt;"><span>&#160;&#160;&#160; </span>}</p>
<p>  </span></p>
<p style="line-height:normal;margin:0;" class="MsoNormal"><span style="font-family:&#39;color:black;font-size:10pt;">}</p>
<p>  </span></p>
<p>&#160;</p>
<p align="justify"><font size="3" face="Georgia">This adapter can be configured via a <strong><em>.browser</em></strong> file placed in <strong><em>App_Browsers</em></strong> folder locally with the web site directory.</font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">browsers</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">browser</span> <span style="color:#ff0000;">refid</span><span style="color:#0000ff;">=&quot;Default&quot;</span> <span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">controlAdapters</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">adapter</span> </pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                <span style="color:#ff0000;">controlType</span><span style="color:#0000ff;">=&quot;System.Web.UI.Page&quot;</span>                            </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                <span style="color:#ff0000;">adapterType</span><span style="color:#0000ff;">=&quot;MyPageAdapter&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">controlAdapters</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">browser</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">browsers</span><span style="color:#0000ff;">&gt;</span></pre>
</p></div>
</div>
<p><font size="3" face="Cambria Math"></font></p>
<p align="justify"><font size="3" face="Georgia">This all above content was related to removing/reducing the Viewstate getting transferred over network. But there is still one more type of state “<strong><em>ControlState</em></strong>”. In layman’s terms, Its the minimal information that a control needs to render and function itself properly after a postback. A more apt definition from </font><a href="http://msdn.microsoft.com/en-us/library/1whwt1k7.aspx" target="_blank"><font size="3" face="Georgia">MSDN</font></a><font size="3" face="Georgia"> is:</font></p>
<blockquote>
<p align="justify"><font size="3" face="Calibri">Control state, introduced in ASP.NET version 2.0, is similar to view state but functionally independent of view state. A page developer can disable view state for the page or for an individual control for performance. However, control state cannot be disabled. Control state is designed for storing a control&#8217;s essential data (such as a pager control&#8217;s page number) that must be available on postback to enable the control to function even when view state has been disabled. By default, the ASP.NET page framework stores control state in the page in the same hidden element in which it stores view state. Even if view state is disabled, or when state is managed using Session, control state travels to the client and back to the server in the page. On postback, ASP.NET deserializes the contents of the hidden element and loads control state into each control that is registered for control state.</font></p>
</blockquote>
<p align="justify"><font size="3" face="Georgia">As it is mentioned in the above description, that ControlState will be traveling with the page all the time. There may come a requirement where we want to have it stored somewhere else other then the page hidden fields. While searching for methods to reduce the viewstate size, i stumbled across </font><a href="http://szokelizer.blogsome.com/2006/11/09/how-to-put-controlstate-into-viewstate-and-how-to-put-viewstate-into-session/" target="_blank"><font size="3" face="Georgia">this</font></a><font size="3" face="Georgia"> post by <em>SZOKELIZER</em>, which describes a way to store the ControlState in session as well. ASP.NET provides a switch “</font><a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.httpcapabilitiesbase.requirescontrolstateinsession.aspx" target="_blank"><font size="3" face="Georgia">RequiresControlStateInSession</font></a><strong><em></em></strong><font size="3" face="Georgia">” which allows to store the control state in session rather then the page itself. So for the sake of completeness I am putting the code that needs to be put to enable storing the control state in session from the above mentioned post.</font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">system.web</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">browserCaps</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">case</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        RequiresControlStateInSession=true</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">case</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">browserCaps</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">  <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">system.web</span><span style="color:#0000ff;">&gt;</span></pre>
</p></div>
</div>
<p>&#160;</p>
<h4>Conclusion</h4>
<p align="justify"><font size="3" face="Georgia">In this post I have written about different mechanisms to reduce size of viewstate that travels along with an asp/aspx page every time. I have tried to covered few of the approaches that can be used but I am sure there can be many more. One such approach suggested by a friend of mine is using <strong><em>HttpHandlers</em></strong> to cut the viewstate from the request and restore it back. I am working on a poc for this. I will post it once it is complete. Please do post a comment, if you have come across any other way to tackle this or if there is some correction in approaches I have described above.</font></p>
Posted in .Net 2.0, ASP.Net, C#, ViewState Tagged: .browser, ControlState, IIS compression, LoadPageStateFromPersistenceMedium, PageAdapter, PageStatePersister, RequiresControlStateInSession, SavePageStateToPersistenceMedium, Session, ViewState, Viewstate compression <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gargmanoj.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gargmanoj.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gargmanoj.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gargmanoj.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gargmanoj.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gargmanoj.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gargmanoj.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gargmanoj.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gargmanoj.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gargmanoj.wordpress.com/161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=161&subd=gargmanoj&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gargmanoj.wordpress.com/2009/09/16/viewstate-compression-in-asp-net-2-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/573160ada16637cc5630116b72fd98de?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gargmanoj</media:title>
		</media:content>
	</item>
		<item>
		<title>Request.ValidateInput() : A common misconception</title>
		<link>http://gargmanoj.wordpress.com/2009/09/07/request-validateinput-a-common-misconception/</link>
		<comments>http://gargmanoj.wordpress.com/2009/09/07/request-validateinput-a-common-misconception/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 12:17:00 +0000</pubDate>
		<dc:creator>Manoj Garg</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[A potentially dangerous Request.Form value was detected from the client]]></category>
		<category><![CDATA[HttpRequestValidationException]]></category>
		<category><![CDATA[Request.ValidateInput()]]></category>
		<category><![CDATA[ValidateRequest]]></category>

		<guid isPermaLink="false">http://gargmanoj.wordpress.com/2009/09/07/request-validateinput-a-common-misconception/</guid>
		<description><![CDATA[Attackers try to exploit smallest possible hole into the security of a website. A common and widely used method is script injection attack or cross site scripting where attacker tries to put some script as input to the website and tries to damage the system. A simplest example could be passing a java script function [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=172&subd=gargmanoj&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p align="justify"><font size="3" face="Cambria">Attackers try to exploit smallest possible hole into the security of a website. A common and widely used method is script injection attack or cross site scripting where attacker tries to put some script as input to the website and tries to damage the system. A simplest example could be passing a java script function that redirects every request to a page to some other site next time onwards or passing a SQL DML statement which deletes/updates record into the database. </font></p>
<p align="justify"><font size="3" face="Cambria">ASP.Net provide some measure to mitigate this risk of script injection. One of such technique is validating each and every input entered by the user before passing it on the server automatically. In this approach IIS parses the input before it is sent to the worker process and checks it for potential dangerous characters lie &lt;, &gt; etc. If any of such character is found in the input request, an exception is thrown, thus saving the site from a possible attack. </font></p>
<p align="justify"><font size="3" face="Cambria">The exception thrown is </font></p>
<blockquote><p align="center"><font size="3" face="Cambria">“A potentially dangerous Request.Form value was detected from the client”</font></p>
</blockquote>
<p align="justify"><font size="3" face="Cambria">In ASP.NET this feature can be applied per page basis or for the entire site depending on the requirement. To enable input request validation for the entire site, set <em><font color="#0000ff">validateRequest</font></em> attribute of <em><font color="#0000ff">page</font></em> section in <em><font color="#0000ff">web.config</font></em> to <em><font color="#0000ff">true</font></em>.</font></p>
<p align="justify"><font size="3" face="Cambria"></font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configuration</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">system.web</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">pages</span> <span style="color:#ff0000;">validateRequest</span><span style="color:#0000ff;">=&quot;false&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">system.web</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configuration</span><span style="color:#0000ff;">&gt;</span></pre>
</p></div>
</div>
<p align="justify"><font size="3" face="Cambria">Similarly, to override the request validation or enable/disable request validation on a page <font color="#0000ff">ValidateRequest</font> attribute of <font color="#0000ff"><a href="http://msdn.microsoft.com/en-us/library/ydy4x04a.aspx" target="_blank">Page</a> </font>directive can be set to <font color="#0000ff">true/false</font> respectively. Setting this attribute to true instructs the IIS to check the sanity of the incoming request before passing it on.</font></p>
<p align="justify"><font size="3" face="Cambria">So this approach won’t let any script to pass through. But there are situations where you need to take a script or the prohibited characters like &lt;,&gt; as input from user, at the same time preventing a misuse of this opportunity of script injection. </font></p>
<p align="justify"><font size="3" face="Cambria">A commonly used approach in ASP.NET for this scenario is:</font></p>
<ol>
<li>
<div align="justify"><font size="3" face="Cambria">Set <font color="#0000ff">ValidateRequest</font> to false for that page. </font></div>
</li>
<li>
<div align="justify"><font size="3" face="Cambria">Encode the input entered by the end user using <font size="3" face="Cambria"><a href="http://msdn.microsoft.com/en-us/library/ms525347.aspx" target="_blank">Server.HtmlEncode()</a>:</font> Encoding ensures that all the stop words(potentially harmful characters) are converted to an equivalent HTML character encoding e.g. “<strong><em>&lt;</em></strong>” is converted to “<strong><em>&amp;lt;</em></strong>” etc. </font></div>
</li>
</ol>
<p align="justify"><font size="3" face="Cambria">I had a similar requirement, few days back, when in our application on “contact us” page, We wanted to allow user to enter html scripts into a text box. So we disabled the <font color="#0000ff">ValidateRequest</font> attribute to false and used <font size="3" face="Cambria"><a href="http://msdn.microsoft.com/en-us/library/ms525347.aspx" target="_blank">Server.HtmlEncode()</a>&#160;</font>method to encode the entered input. But at the same time we didn’t wanted the user to pass something malicious through the query string or the cookies. ASP.NET also provides a method on the <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest(VS.80).aspx" target="_blank">Request</a> object named <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest.validateinput(VS.80).aspx" target="_blank">ValidateInput()</a>, which validates the request input passed by the client to the server. And if something fishy is found in the request an <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequestvalidationexception(VS.80).aspx">HttpRequestValidationException</a> exception is thrown. And this is where the confusion gets in.</font></p>
<p align="justify"><font size="3" face="Cambria">As per <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest.validateinput(VS.85).aspx" target="_blank">MSDN</a>, Request.ValidateInput() method ….</font></p>
<blockquote>
<p align="justify"><font size="3" face="Candara">The </font><a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest(VS.85).aspx"><font size="3" face="Candara">HttpRequest</font></a><font size="3" face="Candara"> class uses input validation flags to track whether to perform validation on the request collections accessed through the <b>Cookies</b>, <b>Form</b>, and <b>QueryString </b>properties. The <b>ValidateInput</b> method sets these flags so that when the get accessors for the <b>Cookies</b>, <b>Form</b>, or <b>QueryString</b> property are invoked, input validation is performed. Validation works by checking all input data against a hard-coded list of potentially dangerous data.</font></p>
<p align="justify"><font size="3" face="Candara">If the validation feature is enabled by page directive or configuration, this method is called during the page&#8217;s <b>ProcessRequest</b> processing phase. The <b>ValidateInput</b> method can be called by your code if the validation feature is not enabled.</font></p>
</blockquote>
<p align="justify"><font size="3" face="Cambria">As this definition says that ValidateInput method does nothing but sets some flags indicating that all access to user input must be validated before using it. But normally developer tend to call Request.ValidateInput() method and then expect it to throw the <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequestvalidationexception(VS.80).aspx">HttpRequestValidationException</a> exception, which will not happen since this method doesn’t throw any exception, rather any access now onwards to input will throw the above mentioned exception.</font></p>
<p align="justify"><font size="3" face="Cambria">Lets disassemble the Request.ValidateInput method.</font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> ValidateInput()</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">{</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>._flags.Set(1);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>._flags.Set(2);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>._flags.Set(4);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>._flags.Set(0x40);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>._flags.Set(0x80);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">}</pre>
</p></div>
</div>
<p align="justify"><font size="3" face="Cambria">As shown in the above code snippet, this method has just some set methods calls. Actually these method set a flag for one of the input approach that can be used by the client. Like querystring, form input , cookie etc. </font></p>
<p align="justify"><font size="3" face="Cambria"><em>So what does this setter method do?? </em>This method is merely an indicator for the getters methods of each of the request fields to check the sanitation of the value before returning the value to the requestor and if there is some invalid input then throw the <a href="http://msdn.microsoft.com/en-us/library/system.web.httprequestvalidationexception(VS.80).aspx">HttpRequestValidationException</a>.</font></p>
<p align="justify"><font size="3" face="Cambria">So to check for invalid input in Form values, we need to access form values collection of the request as Request.Form after the call to Request.ValidateInput(). Following is a sample code for validating Form values, </font></p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:712px;height:227px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;">String firstName = <span style="color:#0000ff;">string</span>.Empty;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;"><span style="color:#0000ff;">try</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;">{
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;">    Request.ValidateInput();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;">    <span style="color:#008000;">//Access the Form value collection. So if there is any non complient input entered by user.. It will throw an exception</span>
</pre>
<pre style="background-color:#ffff00;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;">    System.Collections.Specialized.NameValueCollection nvc = Request.Form;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;"></pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;">    firstName = txtName.Text.Trim();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;">}
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;"><span style="color:#0000ff;">catch</span>(HttpRequestValidationException)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;">{
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;">    firstName = HttpUtility.HtmlEncode(txtName.Text.Trim());
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:14px;margin:0;">}</pre>
</pre>
<p align="justify"><font size="3" face="Cambria Math">here line in yellow color will throw an exception if at all there is some bad data in the input. Then in catch we can use HtmlEncode() to encode the user input.</font></p>
<p align="justify"><font size="3" face="Cambria Math">Similar approach can be used while accessing cookies or QueryString.</font></p>
Posted in .Net 2.0, ASP.Net, C# Tagged: A potentially dangerous Request.Form value was detected from the client, HttpRequestValidationException, Request.ValidateInput(), ValidateRequest <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gargmanoj.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gargmanoj.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gargmanoj.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gargmanoj.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gargmanoj.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gargmanoj.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gargmanoj.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gargmanoj.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gargmanoj.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gargmanoj.wordpress.com/172/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=172&subd=gargmanoj&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gargmanoj.wordpress.com/2009/09/07/request-validateinput-a-common-misconception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/573160ada16637cc5630116b72fd98de?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gargmanoj</media:title>
		</media:content>
	</item>
		<item>
		<title>Fixing &#8220;This page contains secure and nonsecure items&#8221; warning in IE</title>
		<link>http://gargmanoj.wordpress.com/2009/07/17/fixing-this-page-contains-secure-and-nonsecure-items-warning-in-ie/</link>
		<comments>http://gargmanoj.wordpress.com/2009/07/17/fixing-this-page-contains-secure-and-nonsecure-items-warning-in-ie/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 12:11:00 +0000</pubDate>
		<dc:creator>Manoj Garg</dc:creator>
				<category><![CDATA[IE]]></category>
		<category><![CDATA[Security warning]]></category>

		<guid isPermaLink="false">http://gargmanoj.wordpress.com/2009/07/17/fixing-this-page-contains-secure-and-nonsecure-items-warning-in-ie/</guid>
		<description><![CDATA[Ever encountered “This page contains both secure and nonsecure items. Do you want to display the nonsecure items? ” in IE. Well I do and this pesky popup keeps bugging me now n then. Till today, I never bothered about it. I used to click “Yes” no matter what  . I know it’s not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=127&subd=gargmanoj&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><blockquote><p align="justify"><font size="2">Ever encountered “<font color="#0000ff" size="3" face="Georgia">This page contains both secure and nonsecure items. Do you want to display the nonsecure items?</font> ” in IE. Well I do and this pesky popup keeps bugging me now n then. Till today, I never bothered about it. I used to click “Yes” no matter what <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . I know it’s not always safe to do it but who cares <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </font></p>
</blockquote>
<p align="justify"><font size="2"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="CapturedImage_13" border="0" alt="CapturedImage_13" src="http://gargmanoj.files.wordpress.com/2009/07/capturedimage_131.jpg?w=365&#038;h=180" width="365" height="180" /> </font></p>
<p align="justify"><font size="2"><font size="5">T</font>oday I was assigned a bug, in the application I am working on, which says that users are seeing this popup so many times and they are not happy about it. That got me thinking people do care about these pop ups as well <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> . </font></p>
<p align="justify"><font size="2">Ne way, I had to find a solution to get rid of this warning. So after little <a href="http://bit.ly/LLtgp" target="_blank">Binging and Googling</a> I found the solution. So thought about writing my findings though they are available in top 10 search results <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </font></p>
<p align="justify"><font size="2">The reason for this warning is that you are visiting a secure site (HTTPS site) and somewhere behind the scenes that site or page is trying to access a non secure resource be it a complete page or some image. That makes the browser assume that since you are inside a secure site, you should not be getting anything that’s not secure. Like many a times https pages have some images whose source is http for example </font><a href="http://mmyserver/myimages"><font size="2">http://mmyserver/myimages</font></a><font size="2"> .</font></p>
<p align="justify"><font size="2">There are two ways you can get rid of this warning</font></p>
<ol>
<li>
<div align="justify"><font size="2">Change all reference of <strong>http</strong> to <strong>https</strong> in the page. </font></div>
</li>
<li>
<div align="justify"><font size="2"><strong>Lower your guard in IE</strong>: IE has a setting which decide what the browser behavior in case of a non secure content coming while browsing a secure page. This setting is in “<strong>IE</strong> ==&gt; <strong>Tools</strong> ==&gt; <strong>Internet Options</strong> ==&gt; <strong>Security Tab</strong> ==&gt; Click<strong> Custom Level</strong> button” this will open up a list of options for various security settings for IE. Scroll this list to search for “<strong>Display Mixed Content</strong>” option. The “<strong>Prompt</strong>” radio option is selected by default. Change it to “<strong>Enable</strong>” option and click OK. and you are done. The change will take effect immediately. </font></div>
</li>
</ol>
<p align="justify"><font size="2">Following are some of the links which helped me to solved me the issue:</font></p>
<p>1. <a href="http://ask-leo.com/can_i_get_rid_of_the_this_page_contains_both_secure_and_nonsecure_items_warning.html">http://ask-leo.com/can_i_get_rid_of_the_this_page_contains_both_secure_and_nonsecure_items_warning.html</a></p>
<p>2. <a href="http://www.sslshopper.com/article-stop-the-page-contains-secure-and-nonsecure-items-warning.html?jn948e2cf0=2#jotnav948e2cf0db15fcce0a996d225ead01c0">http://www.sslshopper.com/article-stop-the-page-contains-secure-and-nonsecure-items-warning.html?jn948e2cf0=2#jotnav948e2cf0db15fcce0a996d225ead01c0</a></p>
<p>3. <a href="http://www.velocityreviews.com/forums/t152692-this-page-contains-both-secure-and-nonsecure-items.html">http://www.velocityreviews.com/forums/t152692-this-page-contains-both-secure-and-nonsecure-items.html</a></p>
<p>4. <a href="http://blogs.msdn.com/jorman/archive/2006/02/06/526087.aspx">http://blogs.msdn.com/jorman/archive/2006/02/06/526087.aspx</a></p>
<p>5. <a href="http://www.wallpaperama.com/forums/windows-disable-this-page-contains-both-secure-and-nonsecure-items-t274.html">http://www.wallpaperama.com/forums/windows-disable-this-page-contains-both-secure-and-nonsecure-items-t274.html</a></p>
<p>6. <a href="http://www.aspdeveloper.net/tiki-index.php?page=HTMLTipsSSLNonSecureWarning">http://www.aspdeveloper.net/tiki-index.php?page=HTMLTipsSSLNonSecureWarning</a></p>
Posted in IE Tagged: IE, Security warning <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gargmanoj.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gargmanoj.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gargmanoj.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gargmanoj.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gargmanoj.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gargmanoj.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gargmanoj.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gargmanoj.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gargmanoj.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gargmanoj.wordpress.com/127/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=127&subd=gargmanoj&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gargmanoj.wordpress.com/2009/07/17/fixing-this-page-contains-secure-and-nonsecure-items-warning-in-ie/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/573160ada16637cc5630116b72fd98de?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gargmanoj</media:title>
		</media:content>

		<media:content url="http://gargmanoj.files.wordpress.com/2009/07/capturedimage_131.jpg" medium="image">
			<media:title type="html">CapturedImage_13</media:title>
		</media:content>
	</item>
		<item>
		<title>Pagination with JavaScript</title>
		<link>http://gargmanoj.wordpress.com/2009/07/17/pagination-with-javascript/</link>
		<comments>http://gargmanoj.wordpress.com/2009/07/17/pagination-with-javascript/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 08:34:00 +0000</pubDate>
		<dc:creator>Manoj Garg</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[js pagination javascript]]></category>

		<guid isPermaLink="false">http://gargmanoj.wordpress.com/2009/07/17/pagination-with-javascript/</guid>
		<description><![CDATA[Pagination is a must have feature when it comes to display a list of item. List could be collection of search results, a tabular display of names etc etc. When the list is small, pagination is not something we should be worried about, But imagine having a list with 100’s of items to show then [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=120&subd=gargmanoj&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p align="justify"><font size="2">Pagination is a must have feature when it comes to display a list of item. List could be collection of search results, a tabular display of names etc etc. When the list is small, pagination is not something we should be worried about, But imagine having a list with 100’s of items to show then displaying all of them at once on a page is not a good idea. </font></p>
<ul>
<li>
<div align="justify"><font size="2">Viewer of that page have to scroll down a lot if the list if too long</font></div>
</li>
<li>
<div align="justify"><font size="2">Page becomes slower since there are lots of DOM elements on the page</font></div>
</li>
</ul>
<p align="justify"><font size="2">So developers tend to display a small number of items at once to the viewer and then proving him/her the option of navigating to different pages. There are two ways once can implement paging </font></p>
<ol>
<li>
<div align="justify"><font size="2"><strong>Server side paging</strong>: Developer can get only a fixed number of records from the server and display then to the viewer and whenever viewer wants to navigate to a different page, a new request demanding the items from that particular page can be send to the server. In turn server can return records from that page only.</font></div>
</li>
<li>
<div align="justify"><font size="2"><strong>Client side paging</strong>: Depending on the scenario developer can also do the job of showing pages on the client side as well i.e. he/she may request all the items at once and then showing only a set of them to the viewer and providing user with the links to other pages using any scripting language. </font></div>
</li>
</ol>
<p align="justify"><font size="2">I had a situation where it was not possible to have server side pagination due to restriction of the framework I was coding against. So I had no choice but to go with client side paging. I was implementing a search functionality where I would be searching against the lucene index to get the results and then showing those results to the viewer. search results will be displayed a html table. each row in the result table will be used to display one search result. Each search result will have some predefined fields and a summary for that results. Viewer will have an option to show and hide the summary of the result. So one requirement was to have different number of items per page depending on whether summary is visible to the viewer or not.</font></p>
<p align="justify"><font size="2">I took the following approach:</font></p>
<p align="justify"><font size="2">After getting results from server, I used JavaScript to create DOM elements for each of the search results returned. After all the results are created on the page, pagination code was called to show the first page and the pager.</font></p>
<p align="justify"><font size="2">To start I created a JS class named “Pager” which will have all the methods related to the navigation among pages. Pager class had following members:</font></p>
<ul>
<li>
<div align="justify"><font size="2"><strong>tableName</strong> : Name of the table on which pagination has to be applied.</font></div>
</li>
<li>
<div align="justify"><font size="2"><strong>itemsPerPage</strong> : Number of items to show when summary field is visible.</font></div>
</li>
<li>
<div align="justify"><font size="2"><strong>itemsWithoutSmry</strong> : Number of items to show when summary field is not visible to the viewer.</font></div>
</li>
<li>
<div align="justify"><font size="2"><strong>currentItemPerPage</strong> : Number of items currently visible. This value will be equal to either <em>itemsPerPage</em> or <em>itemsWithoutSmry</em>.</font></div>
</li>
<li>
<div align="justify"><font size="2"><strong>currentPage</strong> : current page in the table.</font></div>
</li>
<li>
<div align="justify"><font size="2"><strong>pages</strong> : Total number of pages in the table.</font></div>
</li>
</ul>
<p><font size="2">All the above field will be initialized to some default values when the Object of Pager call will be created. </font></p>
<h6><font size="2">Initialization of the pager</font></h6>
<p><font size="2">This method will initialize the pager object field <strong>pages</strong> by using the total records and items to shown on page. Following code snippet is the init() method.</font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:14pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:1pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//initialize the pager</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">  <span style="color:#0000ff;">this</span>.init = <span style="color:#0000ff;">function</span>() {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#008000;">//check if table exists in the dom</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">if</span>(document.getElementById(tableName) != <span style="color:#0000ff;">null</span>)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">                <span style="color:#008000;">// get the total number of rows in the table</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">var</span> rows = document.getElementById(tableName).rows;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">var</span> records = (rows.length - 1);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">                <span style="color:#008000;">// Calculate the number of pages</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">this</span>.pages = Math.ceil(records / <span style="color:#0000ff;">this</span>.itemsPerPage);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">                <span style="color:#008000;">// set the flag to indicate initialization is complete</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">this</span>.inited = <span style="color:#0000ff;">true</span>;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">   }</pre>
</p></div>
</div>
<h6><font size="2">Showing records of a particular page</font></h6>
<p><font size="2">To do this I will iterate through the rows of the table to show/hide the visibility of these rows depending on the page viewer has requested. Following code snippet shows the methods that do this.</font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:14pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//Show record from a start index to an end index</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">this</span>.showRecords = <span style="color:#0000ff;">function</span>(from, to) {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#008000;">// check if table exists in the DOM</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">if</span>(document.getElementById(tableName) != <span style="color:#0000ff;">null</span>)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#008000;">//Get rows in the table and then set the visibility of the rows between 'from' and 'to'</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">var</span> rows = document.getElementById(tableName).rows;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#008000;">// i starts from 1 to skip table header row and hide rows other then the current page</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">var</span> i = 1; i &lt; rows.length; i++) {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">                <span style="color:#0000ff;">if</span> (i &lt; from || i &gt; to)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">                    rows[i].style.display = <span style="color:#006080;">'none'</span>;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">                <span style="color:#0000ff;">else</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">                    rows[i].style.display = <span style="color:#006080;">''</span>;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">// Method to show a particular pager</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"> <span style="color:#0000ff;">this</span>.showPage = <span style="color:#0000ff;">function</span>(pageNumber) {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">// check if initialization is done</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">if</span> (! <span style="color:#0000ff;">this</span>.inited) {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            alert(<span style="color:#006080;">&quot;not inited&quot;</span>);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">return</span>;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#008000;">//change the CSS style of the old page</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">//each page number indicator in the pager has a naming convention like tablename+pg+pageindex</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">var</span> oldPageAnchor = document.getElementById(<span style="color:#0000ff;">this</span>.tableName+<span style="color:#006080;">'pg'</span>+<span style="color:#0000ff;">this</span>.currentPage);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">if</span>(oldPageAnchor)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        oldPageAnchor.className = <span style="color:#006080;">'pg-normal'</span>;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#008000;">//change the style of the current page</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">this</span>.currentPage = pageNumber;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">var</span> newPageAnchor = document.getElementById(<span style="color:#0000ff;">this</span>.tableName+<span style="color:#006080;">'pg'</span>+<span style="color:#0000ff;">this</span>.currentPage);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">if</span>(newPageAnchor)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        newPageAnchor.className = <span style="color:#006080;">'pg-selected'</span>;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">       <span style="color:#008000;">//calculate current page records index</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">var</span> from = (pageNumber - 1) * <span style="color:#0000ff;">this</span>.currentItemPerPage + 1;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">var</span> to = from + <span style="color:#0000ff;">this</span>.currentItemPerPage - 1;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">//show the records</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">this</span>.showRecords(from, to);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    }   </pre>
</p></div>
</div>
<p>&#160;</p>
<h6><font size="2">Navigating to Next and Previous pages</font></h6>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:14pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//show previous page</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>.prev = <span style="color:#0000ff;">function</span>() {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">if</span> (<span style="color:#0000ff;">this</span>.currentPage &gt; 1)</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">this</span>.showPage(<span style="color:#0000ff;">this</span>.currentPage - 1);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">//show next page</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>.next = <span style="color:#0000ff;">function</span>() {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">if</span> (<span style="color:#0000ff;">this</span>.currentPage &lt; <span style="color:#0000ff;">this</span>.pages) {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">this</span>.showPage(<span style="color:#0000ff;">this</span>.currentPage + 1);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
</p></div>
</div>
<h6><font size="2">Showing the pager bar</font></h6>
<p><font size="2">Following code snippet contains javascript method which will create a div at the end of table containing number from 1 to the total number of pages in the table along with prev and next page links. each link will have a onclick javascript function call to the above mentioned functions.</font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:14pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//show the pager bar</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">// param : @pagerName: name of the pager object</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//  param : @positionId: Id of the div in which the page has to be shown </span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>.showPageNav = <span style="color:#0000ff;">function</span>(pagerName, positionId) {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#008000;">// Check if the pager object has been initialized</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#0000ff;">if</span> (! <span style="color:#0000ff;">this</span>.inited) {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        alert(<span style="color:#006080;">&quot;not inited&quot;</span>);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">return</span>;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#008000;">// check if the div exisits in DOM </span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#0000ff;">if</span>(document.getElementById(positionId) != <span style="color:#0000ff;">null</span>)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">var</span> element = document.getElementById(positionId);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#008000;">// create prev page link with call to prev() method</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">var</span> pagerHtml = <span style="color:#006080;">'&lt;b&gt;&lt;span onclick=&quot;'</span> + pagerName + <span style="color:#006080;">'.prev();&quot; class=&quot;pg-normal&quot;&gt; &amp;#171 Prev &lt;/span&gt; | '</span>;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#008000;">// create numeric page number links</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">var</span> page = 1; page &lt;= <span style="color:#0000ff;">this</span>.pages; page++)</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">              pagerHtml += <span style="color:#006080;">'&lt;span id=&quot;'</span>+<span style="color:#0000ff;">this</span>.tableName+<span style="color:#006080;">'pg'</span> + page + <span style="color:#006080;">'&quot; class=&quot;pg-normal&quot; onclick=&quot;'</span> + pagerName + <span style="color:#006080;">'.showPage('</span> + page + <span style="color:#006080;">');&quot;&gt;'</span> + page + <span style="color:#006080;">'&lt;/span&gt; | '</span>;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#008000;">// Create next page link with call to next() method</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        pagerHtml += <span style="color:#006080;">'&lt;span onclick=&quot;'</span>+pagerName+<span style="color:#006080;">'.next();&quot; class=&quot;pg-normal&quot;&gt; Next »&lt;/span&gt; &lt;/b&gt;'</span>;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#008000;">// chnage the inner html of the pager Div </span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        element.innerHTML = pagerHtml;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
</p></div>
</div>
<h6><font size="2">Adjusting the record count per page with the Summary visibility</font></h6>
<p><font size="2">I added a method to the pager class which takes a Boolean parameter denoting the visibility status of the summary content as input and based on this parameter it changes the current page size. Following code snippet shows the same:</font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:14pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//adjust page according to summay div visibility</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">// param : @isSummaryShown = Visibility status of the summary content for the item</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>.adjustPager = <span style="color:#0000ff;">function</span>(isSummaryShown)</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#008000;">//change the pagesize</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#0000ff;">if</span>(isSummaryShown)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">this</span>.currentItemPerPage = <span style="color:#0000ff;">this</span>.itemsPerPage;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#0000ff;">else</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">this</span>.currentItemPerPage = <span style="color:#0000ff;">this</span>.itemsWithoutSmry;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#008000;">//rebuild pager</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      <span style="color:#0000ff;">if</span>(document.getElementById(tableName) != <span style="color:#0000ff;">null</span>)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">      {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">          <span style="color:#0000ff;">var</span> rows = document.getElementById(tableName).rows;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">          <span style="color:#0000ff;">var</span> records = (rows.length - 1);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">          <span style="color:#0000ff;">this</span>.pages = Math.ceil(records / <span style="color:#0000ff;">this</span>.currentItemPerPage);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">        }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>.showPageNav(<span style="color:#006080;">&quot;pagerObj&quot;</span>, <span style="color:#006080;">'pageNavPosition_Results'</span>);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">this</span>.showPage(1);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
</p></div>
</div>
<h6></h6>
<h6><font size="2">Creating and using Instance of the Pager Class</font></h6>
<p><font size="2">following line shows the signature for the pager class</font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:14pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">function</span> Pager(tableName, itemsPerPage, pageSizeWithoutSummary)</pre>
</p></div>
</div>
<p><font size="2">after the page object is created it must be first initialized, then the pager bar should be created followed by showing the page.</font></p>
<p><font size="2">Following code snippet shows this</font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:14pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">// create a pager obejct by passing tablename, page size</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">var</span> pagerObj = <span style="color:#0000ff;">new</span> Pager(<span style="color:#006080;">'table_AllResults'</span>, 10, 15);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">// init the pager object</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">pagerObj.init();</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//show the pager bar for itens without summary</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">pagerObj.adjustPager(<span style="color:#0000ff;">false</span>);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">//show first page</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:14pt;overflow:visible;border-style:none;margin:0;padding:0;">pagerObj.showPage(1);</pre>
</p></div>
</div>
<pre><font size="2" face="var">I will be uploading a demo soon.</font></pre>
<p><font size="2" face="var">If you have some better way to implement the pagination then please drop a comment.&#160; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </font></p>
<p>&#8211;</p>
Posted in CSS, JavaScript Tagged: js pagination javascript <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gargmanoj.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gargmanoj.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gargmanoj.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gargmanoj.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gargmanoj.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gargmanoj.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gargmanoj.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gargmanoj.wordpress.com/120/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gargmanoj.wordpress.com/120/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gargmanoj.wordpress.com/120/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=120&subd=gargmanoj&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gargmanoj.wordpress.com/2009/07/17/pagination-with-javascript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/573160ada16637cc5630116b72fd98de?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gargmanoj</media:title>
		</media:content>
	</item>
		<item>
		<title>Null-coalescing operator in C#</title>
		<link>http://gargmanoj.wordpress.com/2009/05/12/null-coalescing-operator-in-c/</link>
		<comments>http://gargmanoj.wordpress.com/2009/05/12/null-coalescing-operator-in-c/#comments</comments>
		<pubDate>Tue, 12 May 2009 10:02:00 +0000</pubDate>
		<dc:creator>Manoj Garg</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[??]]></category>
		<category><![CDATA[null-coalescing operator]]></category>

		<guid isPermaLink="false">http://gargmanoj.wordpress.com/2009/05/12/null-coalescing-operator-in-c/</guid>
		<description><![CDATA[While surfing around I can across a term called “null-coalescing operator”. After searching about it, I came to know that C# has an operator ?? . well I didn’t new about it before so thought of writing about it. 
MSDN says
The ?? operator is called the null-coalescing operator and is used to define a default [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=115&subd=gargmanoj&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>While surfing around I can across a term called “null-coalescing operator”. After searching about it, I <a href="http://weblogs.asp.net/scottgu/archive/2007/09/20/the-new-c-null-coalescing-operator-and-using-it-with-linq.aspx" target="_blank">came to know</a> that C# has an operator <strong>?? </strong>. well I didn’t new about it before so thought of writing about it. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms173224.aspx" target="_blank">MSDN</a> says</p>
<blockquote><p><em><font size="4" face="Latha">The <strong>??</strong> operator is called the null-coalescing operator and is used to define a default value for a nullable value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.</font></em></p>
</blockquote>
<p>Example:</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:650px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"><span style="color:#0000ff;">int</span>? x = <span style="color:#0000ff;">null</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"><span style="color:#0000ff;">string</span> str = &quot;<span style="color:#8b0000;">Hello World !!</span>&quot;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"></pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"><span style="color:#0000ff;">int</span> y = x ?? -99; <span style="color:#008000;">// Here Y will be -99 since X is null</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"><span style="color:#0000ff;">string</span> newStr = str ?? &quot;<span style="color:#8b0000;">Default Hello World !!</span>&quot;; <span style="color:#008000;">// here newStr will be &quot;Hello World !!&quot;</span></pre>
</pre>
<p>PS: This operator reminded me of similar functions available in SQL Server like ISNULL, COALESCE</p>
<p>&#8211;</p>
Posted in C# Tagged: ??, null-coalescing operator <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gargmanoj.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gargmanoj.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gargmanoj.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gargmanoj.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gargmanoj.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gargmanoj.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gargmanoj.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gargmanoj.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gargmanoj.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gargmanoj.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=115&subd=gargmanoj&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gargmanoj.wordpress.com/2009/05/12/null-coalescing-operator-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/573160ada16637cc5630116b72fd98de?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gargmanoj</media:title>
		</media:content>
	</item>
		<item>
		<title>Problem with Webdev.webserver.exe when working with web services with non-fixed ports</title>
		<link>http://gargmanoj.wordpress.com/2009/05/06/problem-with-webdevwebserverexe-when-working-with-web-services-with-non-fixed-ports/</link>
		<comments>http://gargmanoj.wordpress.com/2009/05/06/problem-with-webdevwebserverexe-when-working-with-web-services-with-non-fixed-ports/#comments</comments>
		<pubDate>Wed, 06 May 2009 14:16:00 +0000</pubDate>
		<dc:creator>Manoj Garg</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[VS 2005]]></category>
		<category><![CDATA[fixed ports]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[ndoc issue]]></category>
		<category><![CDATA[webdev.webserver.exe]]></category>

		<guid isPermaLink="false">http://gargmanoj.wordpress.com/2009/05/06/problem-with-webdevwebserverexe-when-working-with-web-services-with-non-fixed-ports/</guid>
		<description><![CDATA[Yesterday, a team mate of mine sent an email regarding a problem with his Visual Studio 2005. ASP.NET web server wasn&#8217;t allowing him to debug any Web services. Following is the complete description of his problem:
Summary
In short, the ASP.NET 2.0 development web server (webdev.webserver.exe) on my machine broke after I installed and uninstalled NDoc some [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=114&subd=gargmanoj&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Yesterday, a team mate of mine sent an email regarding a problem with his Visual Studio 2005. ASP.NET web server wasn&#8217;t allowing him to debug any Web services. Following is the complete description of his problem:</p>
<blockquote><p><b>Summary</b></p>
<p>In short, the ASP.NET 2.0 development web server (webdev.webserver.exe) on my machine broke after I installed and uninstalled NDoc some days ago. IIS still works fine. I’ve tried re-registering ASP.NET 2.0 (aspnet_regiis –r from the 2.0 directory) to no avail. Other than re-installing VS 2005, could you recommend a quick fix?</p>
<p><b>Problem Description</b></p>
<p>I am on XP. I had VS 2005 with v2.0 of the framework. Then I installed NDoc recently and that supports only v1.1, so it installed v1.1 on top of v2.0. That is fine because both versions can co-exist but what it did was screw up some settings with:      <br />a) The web server that comes with ASP.NET, the one you run your web services on in debug mode.       <br />b) SQL Server&#8217;s active CLR settings (but this isn&#8217;t bothering me as much)       <br />c) IIS settings (but I fixed this by re-registering IIS with 2.0)       <br />What&#8217;s bothering me to the hilt now is the broken ASP.NET web server won&#8217;t allow me to debug my Web services or even have another project in the same solution create a web reference to it.       <br />I can&#8217;t generate proxies in Visual Studio because of this, nor can I set a web reference to a web service in the same solution (as it involves generating a proxy).       <br />Note that I can call wsdl.exe though. My web services compile, and if I generate a proxy myself through wsdl.exe, deploy my WS locally on IIS, and change the url in the proxy’s constructor to my locally deployed WS, and add the proxy to my client project, it all works fine.</p>
<p>But I don&#8217;t want to deploy my service yet. I just want all projects in the same solution referencing the ws like well-behaved little kids.      <br />When I do try to create a web reference to the WS project in my solution, I keep getting this error:       <br />Server Error in &#8216;/&#8217; Application.       <br />&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;       <br />Parser Error       <br />Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.       <br />Parser Error Message: Could not create type &#8216;DaWS.PhoneDirectory&#8217;.       <br />Source Error:       <br />Line 1:&#160; &lt;%@ WebService Language=&quot;C#&quot; CodeBehind=&quot;PhoneDirectory.asmx.cs&quot;       <br />Line 2:&#160; Class=&quot;DaWS.PhoneDirectory&quot; %&gt;       <br />Source File: /PhoneDirectory.asmx&#160;&#160;&#160; Line: 2       <br />&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;       <br />Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082       <br />It&#8217;s been nagging me for days now and I&#8217;ve been managing with deploying in IIS.       <br />Other than re-install Visual Studio, does anyone have a better solution?       <br />Here&#8217;s what the Event Log says:       <br />Event Type:&#160;&#160;&#160; Warning       <br />Event Source:&#160;&#160;&#160; ASP.NET 2.0.50727.0       <br />Event Category:&#160;&#160;&#160; Web Event       <br />Event ID:&#160;&#160;&#160; 1310       <br />Date:&#160;&#160;&#160;&#160;&#160;&#160;&#160; 06/05/2009       <br />Time:&#160;&#160;&#160;&#160;&#160;&#160;&#160; 12:04:33 AM       <br />User:&#160;&#160;&#160;&#160;&#160;&#160;&#160; N/A       <br />Computer:&#160;&#160;&#160; ABCD       <br />Description:       <br />Event code: 3006       <br />Event message: A parser error has occurred.       <br />Event time: 06/05/2009 12:04:33 AM       <br />Event time (UTC): 05/05/2009 6:34:33 PM       <br />Event ID: c41a610193fa4c2e810dad096709b0b0       <br />Event sequence: 4       <br />Event occurrence: 1       <br />Event detail code: 0       <br />Application information:       <br />&#160;&#160;&#160; Application domain: a54e0deb-1-128860220726250000       <br />&#160;&#160;&#160; Trust level: Full       <br />&#160;&#160;&#160; Application Virtual Path: /       <br />&#160;&#160;&#160; Application Path: C:\Me\rnd\DotNet\DoIndexersGetSerialized\DaWS\       <br />&#160;&#160;&#160; Machine name: ABCD       <br />Process information:       <br />&#160;&#160;&#160; Process ID: 660       <br />&#160;&#160;&#160; Process name: webdev.webserver.exe       <br />&#160;&#160;&#160; Account name: Domain\Me</p>
</blockquote>
<p>Some one finally caught the issue, following are his observations and solution:</p>
<blockquote><p>Just wondering if you are using a fixed port or not for the web service that you try to reference. Because Web Dev by default always host the app on different port and if that the case you will not be able to get it working ever.</p>
<p>If you are not using the fixed port I would suggest you to use the “External Tool” options present in the VS’s Tool menu and create a fixed web dev location that is associated with you web service and you should be able get it working.</p>
<p>I may be telling you the thing that you might have tried but just incase if you haven’t please give it a try. </p>
<p>Please have a look at this URL and probably give you the solution you are looking for.</p>
<p><a href="http://weblogs.asp.net/scottgu/archive/2005/11/21/431138.aspx">http://weblogs.asp.net/scottgu/archive/2005/11/21/431138.aspx</a></p>
</blockquote>
<p>This did the trick. The problem was solved. So I thought to write it here as someone else may face the same issue. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
Posted in .Net 2.0, ASP.Net, VS 2005 Tagged: fixed ports, IIS, ndoc issue, webdev.webserver.exe <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gargmanoj.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gargmanoj.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gargmanoj.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gargmanoj.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gargmanoj.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gargmanoj.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gargmanoj.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gargmanoj.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gargmanoj.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gargmanoj.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=114&subd=gargmanoj&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gargmanoj.wordpress.com/2009/05/06/problem-with-webdevwebserverexe-when-working-with-web-services-with-non-fixed-ports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/573160ada16637cc5630116b72fd98de?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gargmanoj</media:title>
		</media:content>
	</item>
		<item>
		<title>Passing an object by REF inside a foreach loop</title>
		<link>http://gargmanoj.wordpress.com/2009/04/22/passing-an-object-by-ref-inside-a-foreach-loop/</link>
		<comments>http://gargmanoj.wordpress.com/2009/04/22/passing-an-object-by-ref-inside-a-foreach-loop/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 11:05:00 +0000</pubDate>
		<dc:creator>Manoj Garg</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Collections & Generics]]></category>
		<category><![CDATA[pass by ref]]></category>

		<guid isPermaLink="false">http://gargmanoj.wordpress.com/2009/04/22/passing-an-object-by-ref-inside-a-foreach-loop/</guid>
		<description><![CDATA[Passing an object by REF inside a foreach loop<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=110&subd=gargmanoj&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p align="justify"><font size="5">I</font>ts summer time in India and its hard to resist drowsiness in the afternoon specially when you had a heavy lunch. So this afternoon while I was trying to take a nap, no one was watching <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> , a friend of mine pinged me on IM, and says “<em><font size="3" face="Cambria">dude, can’t I pass an object as ref inside a foreach loop?</font></em>”, well my first reaction was “<font size="3" face="Cambria"><em>of course you can!!!</em></font> “ but then I realized that its an iterator&#160; and I can’t modify an object I am iterating on. </p>
<p align="justify">I opened a new instance of Visual Studio and create a new console application. In this application created a new class named <strong><em>testref</em></strong> with just two fields, one <em>string</em> and another one an <em>int</em>. In the main method created a generic list of type <strong><em>testref</em></strong> and filled it with five <strong><em>testref</em></strong> object. Then tried to loop through it and pass the loop variable as <strong><em>ref</em></strong> in a function. He was right, C# compiler throws an error “<font size="3" face="Cambria"><em>Cannot pass &#8216;xxyzobj&#8217; as <strong>a</strong> <strong>ref</strong> or out argument because it is <strong>a</strong> &#8216;foreach iteration variable&#8217;</em></font>”. following snippet shows the initial set of code</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:662px;height:366px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> <span style="color:#0000ff;">class</span> Program
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">    {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">        <span style="color:#0000ff;">class</span> testref
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">        {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> val { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> a {<span style="color:#0000ff;">get</span>;<span style="color:#0000ff;">set</span>;}
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"></pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            <span style="color:#0000ff;">public</span> testref(<span style="color:#0000ff;">string</span> s)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">                val = s;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">                a = 0;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">        }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"></pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">        <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Main(<span style="color:#0000ff;">string</span>[] args)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">        {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            List&lt;testref&gt; testcol = <span style="color:#0000ff;">new</span> List&lt;testref&gt;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"></pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            testcol.Add(<span style="color:#0000ff;">new</span> testref(&quot;<span style="color:#8b0000;">One</span>&quot;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            testcol.Add(<span style="color:#0000ff;">new</span> testref(&quot;<span style="color:#8b0000;">two</span>&quot;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            testcol.Add(<span style="color:#0000ff;">new</span> testref(&quot;<span style="color:#8b0000;">three</span>&quot;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            testcol.Add(<span style="color:#0000ff;">new</span> testref(&quot;<span style="color:#8b0000;">four</span>&quot;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            testcol.Add(<span style="color:#0000ff;">new</span> testref(&quot;<span style="color:#8b0000;">five</span>&quot;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"></pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            <span style="color:#0000ff;">foreach</span> (testref s <span style="color:#0000ff;">in</span> testcol)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            {
</pre>
<pre style="background-color:#ffff00;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">               MethodWithRef(<span style="color:#0000ff;">ref</span> s);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"></pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            Console.ReadLine();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">        }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"></pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">        <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> MethodWithRef(<span style="color:#0000ff;">ref</span> testref str)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">        {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            str.val = str.val + &quot;<span style="color:#8b0000;"> not</span>&quot;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">            str.a = (<span style="color:#0000ff;">new</span> Random()).Next();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">        }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"></pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">}</pre>
</pre>
<p align="justify">In above code snippet, line in yellow will give the compilation error. Since this is a C# complier restriction there are couple of workaround to this situation.</p>
<ul>
<li><strong>Have a <em>temporary</em> variable and then pass this variable as the ref parameter in the method</strong>: </li>
</ul>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:650px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">testref tempObj;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"><span style="color:#0000ff;">foreach</span> (testref s <span style="color:#0000ff;">in</span> testcol)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">{
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">    tempObj = s;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">    MethodWithRef(<span style="color:#0000ff;">ref</span> tempObj);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">}</pre>
</pre>
<ul>
<li><strong>Use <a href="http://msdn.microsoft.com/en-us/library/bwabdf9z.aspx" target="_blank"><em>List.ForEach()</em></a> method to apply an action on all the objects in the list</strong>: </li>
</ul>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:753px;height:328px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"><span style="color:#008000;">// Inside the main method pass the function name </span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"><span style="color:#008000;">// you want to apply on each object</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">testcol.ForEach(MethodWithoutRef);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"></pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"><span style="color:#008000;">//Method to be applied on all the objects</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"><span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> MethodWithoutRef(testref str)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">{
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">   str.val = str.val + &quot;<span style="color:#8b0000;"> not</span>&quot;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">   str.a = (<span style="color:#0000ff;">new</span> Random()).Next();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">}</pre>
</pre>
<p>So that was it.. problem was solved…</p>
<p>PS: If you have some more ways this can be solved, Please do share.</p>
<p>&#8211;</p>
<p>Manoj</p>
Posted in C#, Collections &amp; Generics Tagged: pass by ref <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gargmanoj.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gargmanoj.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gargmanoj.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gargmanoj.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gargmanoj.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gargmanoj.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gargmanoj.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gargmanoj.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gargmanoj.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gargmanoj.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=110&subd=gargmanoj&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gargmanoj.wordpress.com/2009/04/22/passing-an-object-by-ref-inside-a-foreach-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/573160ada16637cc5630116b72fd98de?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gargmanoj</media:title>
		</media:content>
	</item>
		<item>
		<title>Credit Crisis: How it happened??</title>
		<link>http://gargmanoj.wordpress.com/2009/04/09/credit-crisis-how-it-happened/</link>
		<comments>http://gargmanoj.wordpress.com/2009/04/09/credit-crisis-how-it-happened/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 05:29:00 +0000</pubDate>
		<dc:creator>Manoj Garg</dc:creator>
				<category><![CDATA[Non Technical]]></category>
		<category><![CDATA[Credit Crisis]]></category>
		<category><![CDATA[Recession]]></category>

		<guid isPermaLink="false">http://gargmanoj.wordpress.com/2009/04/09/credit-crisis-how-it-happened/</guid>
		<description><![CDATA[Well nowadays everyone says, its economic downturn these days.. World economy is going through troubled times.. World is under recession … so on n so forth.. All headlines related to this have one word in common . CREDIT CRISIS .. I always wondered how it all started… So while stumbling across the web found 2 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=108&subd=gargmanoj&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Well nowadays everyone says, its economic downturn these days.. World economy is going through troubled times.. World is under recession … so on n so forth.. All headlines related to this have one word in common . <strong><em><font color="#0000ff" size="3" face="Century Gothic">CREDIT CRISIS</font></em></strong> .. I always wondered how it all started… So while stumbling across the web found 2 videos giving a good visualization and answer to the big question … <em><strong>How It all started…?</strong></em> so thought of sharing these with all..</p>
<p>&#160;</p>
<div style="width:425px;display:block;float:none;margin-left:auto;margin-right:auto;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:007c78e9-48ba-499b-aca7-689824fd73e9" class="wlWriterEditableSmartContent">
<div><span style="text-align:center; display: block;"><a href="http://gargmanoj.wordpress.com/2009/04/09/credit-crisis-how-it-happened/"><img src="http://img.youtube.com/vi/Q0zEXdDO5JU/2.jpg" alt="" /></a></span></div>
</div>
<p>&#160;</p>
<div style="width:425px;display:block;float:none;margin-left:auto;margin-right:auto;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:d3e7630f-606f-4614-995f-e441def617eb" class="wlWriterEditableSmartContent">
<div><span style="text-align:center; display: block;"><a href="http://gargmanoj.wordpress.com/2009/04/09/credit-crisis-how-it-happened/"><img src="http://img.youtube.com/vi/iYhDkZjKBEw/2.jpg" alt="" /></a></span></div>
</div>
<p>&#160;</p>
<p>&#8211;</p>
Posted in Non Technical Tagged: Credit Crisis, Recession <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gargmanoj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gargmanoj.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gargmanoj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gargmanoj.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gargmanoj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gargmanoj.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gargmanoj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gargmanoj.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gargmanoj.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gargmanoj.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gargmanoj.wordpress.com&blog=1375338&post=108&subd=gargmanoj&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gargmanoj.wordpress.com/2009/04/09/credit-crisis-how-it-happened/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/573160ada16637cc5630116b72fd98de?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gargmanoj</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/Q0zEXdDO5JU/2.jpg" medium="image" />

		<media:content url="http://img.youtube.com/vi/iYhDkZjKBEw/2.jpg" medium="image" />
	</item>
	</channel>
</rss>