Troy Goode


PagedList can haz HtmlHelperz?

Wow, has it already been almost two years since my last post?

Back in March I made some modifications to the PagedList library I've been working on the last couple of years to (finally) add an HTML Helper that can generate the HTML paging code you frequently will use alongside the PagedList library. Over the last few days I have tweaked everything a bit more and am now quite happy with where the library sits.

Installation

You can install via Nuget:

Install-Package PagedList
Install-Package PagedList.Mvc

Alternatively, download the source straight from GitHub.

What does PagedList do again?

The first package contains the core PagedList library, which allows you to do this:

Okay, so what is PagedList.Mvc then?

The second package contains the new HTML Helper which lets you render pagers that look like this:

IMAGE

Note: All elements rendered by the HTML Helper have CSS classes applied to allow you to easily modify styling.

You call the HTML Helper like so:

Customizing the Rendering Options

There are several out-of-the-box render configurations as you can see above, and you can also pass ad-hoc render configurations to the render method (also shown above). Sometimes, though, you want to create a render configuration that will be used repeatedly throughout your application. This is easy to do as well:

For more information on the available rendering option settings, check PagedListRenderingOptions.cs on GitHub.