<?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/"
	>

<channel>
	<title>Martijn Boland &#187; Paging</title>
	<atom:link href="http://blogs.taiga.nl/martijn/tag/paging/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.taiga.nl/martijn</link>
	<description>New adventures in .NET</description>
	<lastBuildDate>Wed, 25 Jan 2012 22:27:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MvcPaging 1.0.2</title>
		<link>http://blogs.taiga.nl/martijn/2011/12/07/mvcpaging-1-0-2/</link>
		<comments>http://blogs.taiga.nl/martijn/2011/12/07/mvcpaging-1-0-2/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 21:57:46 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[Paging]]></category>
		<category><![CDATA[Razor]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2011/12/07/mvcpaging-1-0-2/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2011/12/07/mvcpaging-1-0-2/' addthis:title='MvcPaging 1.0.2 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>A new version of the MvcPaging component is available via NuGet with the following changes: Added ItemStart and ItemEnd properties to IPagedList (Displaying items {ItemStart} &#8211; {ItemEnd}). Non-canonical url&#8217;s for page 1 (https://github.com/martijnboland/MvcPaging/issues/2). So the core library hasn’t changed much, and in all honesty, I think it’s pretty much done. Please leave a reply if <a href="http://blogs.taiga.nl/martijn/2011/12/07/mvcpaging-1-0-2/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2011/12/07/mvcpaging-1-0-2/' addthis:title='MvcPaging 1.0.2 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>A new version of the <a href="https://github.com/martijnboland/mvcpaging">MvcPaging</a> component is available via <a href="https://nuget.org/packages/MvcPaging">NuGet</a> with the following changes:</p>
<ul>
<li>Added ItemStart and ItemEnd properties to IPagedList (Displaying items {ItemStart} &#8211; {ItemEnd}). </li>
<li>Non-canonical url&#8217;s for page 1 (<a href="https://github.com/martijnboland/MvcPaging/issues/2">https://github.com/martijnboland/MvcPaging/issues/2</a>).</li>
</ul>
<p>So the core library hasn’t changed much, and in all honesty, I think it’s pretty much done. Please leave a reply if you think otherwise.</p>
<p>What did change substantially is the sample application. It was still very much ASP.NET 1.0 with WebForms views. This is now a proper ASP.NET MVC 3 application with Razor views and the default ASP.NET MVC 4.0 template for look &amp; feel.</p>
<p>&#160;<a href="http://blogs.taiga.nl/martijn/wp-content/uploads/2011/12/Screenshot.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Screenshot" border="0" alt="Screenshot" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2011/12/Screenshot_thumb.png" width="640" height="400" /></a></p>
<p>The sample application can be found at <a href="https://github.com/martijnboland/mvcpaging">GitHub</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2011/12/07/mvcpaging-1-0-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NuGet package for MVC pager</title>
		<link>http://blogs.taiga.nl/martijn/2011/05/12/nuget-package-for-mvc-pager/</link>
		<comments>http://blogs.taiga.nl/martijn/2011/05/12/nuget-package-for-mvc-pager/#comments</comments>
		<pubDate>Thu, 12 May 2011 15:15:35 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[NuGet]]></category>
		<category><![CDATA[Paging]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2011/05/12/nuget-package-for-mvc-pager/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2011/05/12/nuget-package-for-mvc-pager/' addthis:title='NuGet package for MVC pager '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>It’s now possible to add the MVC pager to your own project with NuGet. Or from Visual Studio with ‘Manage NuGet Packages&#8230;’ and then search for ‘MvcPaging’. After installing, you can immediately use the Pager HtmlHelper in your views: et voilà! We also have include the IPagedList for your convenience: For more info, check out <a href="http://blogs.taiga.nl/martijn/2011/05/12/nuget-package-for-mvc-pager/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2011/05/12/nuget-package-for-mvc-pager/' addthis:title='NuGet package for MVC pager '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>It’s now possible to add the <a href="https://github.com/martijnboland/MvcPaging">MVC pager</a> to your own project with <a href="http://nuget.org/">NuGet</a>.</p>
<p><a href="http://blogs.taiga.nl/martijn/wp-content/uploads/2011/05/image4.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2011/05/image_thumb4.png" alt="image" width="600" height="77" border="0" /></a></p>
<p>Or from Visual Studio with ‘Manage NuGet Packages&#8230;’ and then search for ‘MvcPaging’.</p>
<p>After installing, you can immediately use the Pager HtmlHelper in your views:</p>
<p><a href="http://blogs.taiga.nl/martijn/wp-content/uploads/2011/05/image5.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2011/05/image_thumb5.png" alt="image" width="600" height="187" border="0" /></a></p>
<p>et voilà!</p>
<p><a href="http://blogs.taiga.nl/martijn/wp-content/uploads/2011/05/image6.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2011/05/image_thumb6.png" alt="image" width="600" height="392" border="0" /></a></p>
<p>We also have include the IPagedList for your convenience:</p>
<p><a href="http://blogs.taiga.nl/martijn/wp-content/uploads/2011/05/image7.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://blogs.taiga.nl/martijn/wp-content/uploads/2011/05/image_thumb7.png" alt="image" width="600" height="331" border="0" /></a></p>
<p>For more info, check out <a href="http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/">the original blogpost</a> that started it or the <a href="https://github.com/martijnboland/MvcPaging">github project page</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2011/05/12/nuget-package-for-mvc-pager/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>MVC Pager update: now with AJAX support</title>
		<link>http://blogs.taiga.nl/martijn/2011/03/23/mvc-pager-update-now-with-ajax-support/</link>
		<comments>http://blogs.taiga.nl/martijn/2011/03/23/mvc-pager-update-now-with-ajax-support/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 13:26:59 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Paging]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2011/03/23/mvc-pager-update-now-with-ajax-support/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2011/03/23/mvc-pager-update-now-with-ajax-support/' addthis:title='MVC Pager update: now with AJAX support '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>The MVC pager now has support for AJAX scenario’s, thanks to Bart Lenaerts. This was my first GitHub pull request and everything went pretty smoothly. Check out the demo application for an example. Visit the GitHub project page to download the solution.]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2011/03/23/mvc-pager-update-now-with-ajax-support/' addthis:title='MVC Pager update: now with AJAX support '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>The <a href="http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/">MVC pager</a> now has support for AJAX scenario’s, thanks to <a href="https://github.com/blenaerts">Bart Lenaerts</a>. This was my first <a href="https://github.com">GitHub</a> pull request and everything went pretty smoothly.</p>
<p>Check out the demo application for an example. Visit the <a href="https://github.com/martijnboland/MvcPaging">GitHub project</a> page to download the solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2011/03/23/mvc-pager-update-now-with-ajax-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MVC Pager update</title>
		<link>http://blogs.taiga.nl/martijn/2011/02/11/mvc-pager-update/</link>
		<comments>http://blogs.taiga.nl/martijn/2011/02/11/mvc-pager-update/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 12:16:19 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Paging]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2011/02/11/mvc-pager-update/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2011/02/11/mvc-pager-update/' addthis:title='MVC Pager update '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Just a short message to let you know that the MVC Pager demo is upgraded to ASP.NET MVC3 and VS 2010. Get it at https://github.com/martijnboland/MvcPaging.]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2011/02/11/mvc-pager-update/' addthis:title='MVC Pager update '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Just a short message to let you know that the <a href="http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/">MVC Pager demo</a> is upgraded to ASP.NET MVC3 and VS 2010. Get it at <a title="https://github.com/martijnboland/MvcPaging" href="https://github.com/martijnboland/MvcPaging">https://github.com/martijnboland/MvcPaging</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2011/02/11/mvc-pager-update/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Paging demo for ASP.NET MVC 2</title>
		<link>http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/</link>
		<comments>http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 18:27:58 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Area]]></category>
		<category><![CDATA[Paging]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/' addthis:title='Paging demo for ASP.NET MVC 2 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>During work, I discovered that the pager that I created a while ago didn’t work properly when using ASP.NET MVC2 area’s. The links that were generated didn’t count for the current area that the controller and views were in, resulting in wrong urls. Luckily the ASP.NET MVC team also ran into this issue and created <a href="http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/' addthis:title='Paging demo for ASP.NET MVC 2 '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>During work, I discovered that the <a href="http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/" target="_blank">pager that I created a while ago</a> didn’t work properly when using ASP.NET MVC2 area’s. The links that were generated didn’t count for the current area that the controller and views were in, resulting in wrong urls. Luckily the ASP.NET MVC team also ran into this issue and created an GetVirtualPathForArea() extension method on RouteCollection. Calling this one, instead of GetVirtualPath() made things work properly in area’s.</p>
<p>You can get the code for ASP.NET MVC 2 at <a title="http://github.com/martijnboland/MvcPaging/tree/mvc2" href="http://github.com/martijnboland/MvcPaging/tree/mvc2">http://github.com/martijnboland/MvcPaging/tree/mvc2</a> (mvc2 branch of the MvcPaging repository).</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2010/01/27/paging-demo-for-asp-net-mvc-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Paging demo upgraded to ASP.NET MVC RC</title>
		<link>http://blogs.taiga.nl/martijn/2009/02/04/paging-demo-upgraded-to-aspnet-mvc-rc/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/02/04/paging-demo-upgraded-to-aspnet-mvc-rc/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 11:04:53 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Paging]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/2009/02/04/paging-demo-upgraded-to-aspnet-mvc-rc/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2009/02/04/paging-demo-upgraded-to-aspnet-mvc-rc/' addthis:title='Paging demo upgraded to ASP.NET MVC RC '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>The sample project that belongs to the Paging with ASP.NET MVC post is upgraded to ASP.NET MVC RC. Get it from here.]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2009/02/04/paging-demo-upgraded-to-aspnet-mvc-rc/' addthis:title='Paging demo upgraded to ASP.NET MVC RC '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>The sample project that belongs to <a href="http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/" target="_blank">the Paging with ASP.NET MVC post</a> is upgraded to ASP.NET MVC RC. <a href="http://blogs.taiga.nl/martijn/wp-content/uploads/2008/08/mvcpaging-rc1.zip">Get it from here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/02/04/paging-demo-upgraded-to-aspnet-mvc-rc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Paging demo upgraded to ASP.NET MVC Beta</title>
		<link>http://blogs.taiga.nl/martijn/2009/01/16/paging-demo-upgraded-to-aspnet-mvc-beta/</link>
		<comments>http://blogs.taiga.nl/martijn/2009/01/16/paging-demo-upgraded-to-aspnet-mvc-beta/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 11:48:10 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Paging]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/archive/2009/01/16/paging-demo-upgraded-to-asp.net-mvc-beta.aspx</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2009/01/16/paging-demo-upgraded-to-aspnet-mvc-beta/' addthis:title='Paging demo upgraded to ASP.NET MVC Beta '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>The post about paging in ASP.NET MVC still gets many hits, but the demo was created with ASP.NET MVC preview 5, so therefore I upgraded the demo to ASP.NET MVC Beta. I also removed a little bug that occurred when paging an already filtered list. You can download the updated demo here.]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2009/01/16/paging-demo-upgraded-to-aspnet-mvc-beta/' addthis:title='Paging demo upgraded to ASP.NET MVC Beta '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>The <a href="http://blogs.taiga.nl/martijn/2008/08/27/paging-with-asp.net-mvc">post about paging in ASP.NET MVC</a> still gets many hits, but the demo was created with ASP.NET MVC preview 5, so therefore I upgraded the demo to ASP.NET MVC Beta. I also removed a little bug that occurred when paging an already filtered list.</p>
<p><a href="http://blogs.taiga.nl/martijn/wp-content/uploads/subtext/mvcpaging-mvc-beta.zip" target="_blank">You can download the updated demo here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2009/01/16/paging-demo-upgraded-to-aspnet-mvc-beta/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Paging with ASP.NET MVC</title>
		<link>http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/</link>
		<comments>http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 15:50:23 +0000</pubDate>
		<dc:creator>martijn</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Paging]]></category>

		<guid isPermaLink="false">http://blogs.taiga.nl/martijn/archive/2008/08/27/paging-with-asp.net-mvc.aspx</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/' addthis:title='Paging with ASP.NET MVC '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Updated 2011-05-12: Added NuGet package: http://blogs.taiga.nl/martijn/2011/05/12/nuget-package-for-mvc-pager/ Updated 2011-03-22: Changed download link: https://github.com/martijnboland/MvcPaging. See also http://blogs.taiga.nl/martijn/2011/03/23/mvc-pager-update-now-with-ajax-support/ Updated 2009-02-04: Upgraded source and demo to ASP.NET MVC RC1 Updated 2009-01-16: Upgraded source and demo to ASP.NET MVC Beta Updated 2008-09-09: Source and Demo now use ASP.NET MVC preview 5 On my latest gig, we used ASP.NET MVC and it <a href="http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/"> read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/' addthis:title='Paging with ASP.NET MVC '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p><em>Updated 2011-05-12: Added NuGet package: <a title="NuGet package for MVC pager" href="http://blogs.taiga.nl/martijn/2011/05/12/nuget-package-for-mvc-pager/">http://blogs.taiga.nl/martijn/2011/05/12/nuget-package-for-mvc-pager/</a></em></p>
<p><em>Updated 2011-03-22: Changed download link: <a href="https://github.com/martijnboland/MvcPaging">https://github.com/martijnboland/MvcPaging</a>. See also <a title="http://blogs.taiga.nl/martijn/2011/03/23/mvc-pager-update-now-with-ajax-support/" href="http://blogs.taiga.nl/martijn/2011/03/23/mvc-pager-update-now-with-ajax-support/">http://blogs.taiga.nl/martijn/2011/03/23/mvc-pager-update-now-with-ajax-support/</a></em></p>
<p><em>Updated 2009-02-04: Upgraded source and demo to ASP.NET MVC RC1</em></p>
<p><em>Updated 2009-01-16: Upgraded source and demo to ASP.NET MVC Beta<br />
</em></p>
<p><em>Updated 2008-09-09: Source and Demo now use ASP.NET MVC preview 5</em></p>
<p>On my latest gig, we used <a href="http://asp.net/mvc" target="_blank">ASP.NET MVC</a> and it was a very pleasant experience! Very clean code, clean html output and the productivity was great (which is not very common when using a technology for the first time).</p>
<p>Of course, since ASP.NET MVC isn&#8217;t finished yet, it leaves something to desire. At one time we needed paging and there isn&#8217;t an out-of-the-box solution for it (yet). Some googling revealed that others had already addressed this, but to be honest, I wasn&#8217;t entirely pleased with the solutions, so I grabbed the best parts and build a generic solution out of it.</p>
<p><a href="#download">I&#8217;m in a hurry, take me to the download immediately</a></p>
<h3>IPagedList&lt;T&gt;</h3>
<p>First, there was the PagedList&lt;T&gt; that Scott Guthrie already used in one of the earliest MVC demo&#8217;s and that later appeared in improved incarnations from <a href="http://blog.wekeroad.com/2007/12/10/aspnet-mvc-pagedlistt/" target="_blank">Rob Conery</a> and  <a href="http://www.squaredroot.com/post/2008/07/08/PagedList-Strikes-Back.aspx" target="_blank">Troy Goode</a>. This was a nice starting point, especially because we also used LINQ To SQL as our data access layer. To provide an extra extension point, I created an IPagedList&lt;T&gt; interface instead of using the PagedList&lt;T&gt; directly.</p>
<pre class="brush: csharp;">public interface IPagedList&lt;T&gt; : IList&lt;T&gt;
{
    int PageCount { get; }
    int TotalItemCount { get; }
    int PageIndex { get; }
    int PageNumber { get; }
    int PageSize { get; }
    bool HasPreviousPage { get; }
    bool HasNextPage { get; }
    bool IsFirstPage { get; }
    bool IsLastPage { get; }
}</pre>
<h3>Html.Pager()</h3>
<p>After choosing the IPagedList&lt;T&gt; implementation I started thinking about how I could create an HtmlHelper extension method that renders the page links. First, I made the mistake to couple the helper to the IPagedList&lt;T&gt; and it took me a little while to realize that a paging HTML helper doesn&#8217;t need anything to know about the underlying data source. It&#8217;s sole purpose is to generate a list of hyperlinks for pages and the only thing we need to know is the total amount of items, the page size and the current page. This is what the most basic HtmlHelper extension looks like:</p>
<pre class="brush: csharp;">public static string Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount)</pre>
<p>We&#8217;re assuming that the page links point to the the current controller and current action. Alternatively, it&#8217;s possible to supply a different action:</p>
<pre class="brush: csharp;">public static string Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, string actionName)</pre>
<p>Combining the Pager html helper and IPagedList&lt;T&gt; in a view page (that inherits from ViewPage&lt;IPagedList&lt;Product&gt;&gt;):</p>
<pre class="brush: xml;">&lt;table class="grid"&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;Product name&lt;/th&gt;
            &lt;th&gt;Category&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        &lt;% foreach (var product in Model) { %&gt;
            &lt;tr&gt;
                &lt;td&gt;&lt;%= product.Name %&gt;&lt;/td&gt;
                &lt;td&gt;&lt;%= product.Category %&gt;&lt;/td&gt;
            &lt;/tr&gt;
        &lt;% } %&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;div class="pager"&gt;
    &lt;%= Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount) %&gt;
&lt;/div&gt;</pre>
<p>results in this:</p>
<p><a href="http://blogs.taiga.nl/martijn/wp-content/uploads/subtext/WindowsLiveWriter/PagingwithASP.NETMVC_D952/aspnetmvc-pager_2.png"><img style="border-width: 0pt;" src="http://blogs.taiga.nl/martijn/wp-content/uploads/subtext/WindowsLiveWriter/PagingwithASP.NETMVC_D952/aspnetmvc-pager_thumb.png" alt="aspnetmvc-pager" width="721" height="542" border="0" /></a></p>
<p>You probably recognize the digg-style appearance of the pager. Thanks to the ASP.NET MVC sample application <a href="http://www.codeplex.com/Kigg" target="_blank">KIGG</a> for inspiration <img src='http://blogs.taiga.nl/martijn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Internally, the pager uses RouteTable.Routes.GetVirtualPath() to render the url&#8217;s so the page url&#8217;s can be configured via routing to create nice looking url&#8217;s like for example &#8216;/Categories/Shoes/Page/1&#8242; instead of &#8216;/Paging/ViewByCategory?name=Shoes&amp;page=1&#8242;.</p>
<h3>Advanced scenarios</h3>
<p>Many scenarios where you want to use paging also use filtering. It&#8217;s possible to pass extra parameters to the Pager helper via a RouteValueDictionary or an anonymous type. This adds these parameters to the page links that are generated:</p>
<pre class="brush: xml;">&lt;div class="pager"&gt;
    &lt;%= Html.Pager(ViewData.Model.PageSize, ViewData.Model.PageNumber, ViewData.Model.TotalItemCount, new { categoryname = ViewData["CategoryDisplayName"] } )%&gt;
&lt;/div&gt;</pre>
<p><a href="http://blogs.taiga.nl/martijn/wp-content/uploads/subtext/WindowsLiveWriter/PagingwithASP.NETMVC_D952/aspnetmvc-pager-2_2.png"><img style="border-width: 0pt;" src="http://blogs.taiga.nl/martijn/wp-content/uploads/subtext/WindowsLiveWriter/PagingwithASP.NETMVC_D952/aspnetmvc-pager-2_thumb.png" alt="aspnetmvc-pager-2" width="721" height="542" border="0" /></a></p>
<p>That&#8217;s it. A complete solution with demo project can be downloaded below. Feel free to leave any comments or remarks. One of the things I&#8217;m not happy about is that I failed to properly unit test the pager, but that&#8217;s for a different post.</p>
<h3><a name="download"></a>Download</h3>
<p><a href="https://github.com/martijnboland/MvcPaging">Download the paging sample solution, incl. the demo MVC web project</a></p>
<p>Check also the AJAX version of the pager written by Daniel Iglesias: <a title="http://danieliglesiaseng.blogspot.com/2010/01/ajax-paging-with-aspnet-mvc.html" href="http://danieliglesiaseng.blogspot.com/2010/01/ajax-paging-with-aspnet-mvc.html">http://danieliglesiaseng.blogspot.com/2010/01/ajax-paging-with-aspnet-mvc.html</a>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

