• Stars
    star
    290
  • Rank 142,981 (Top 3 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 15 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ASP.NET MVC Paging HTML helper

The MvcPaging library contains an ASP.NET MVC HTML helper that renders a pager based on given parameters. A live demo can be found at http://demo.taiga.nl/mvcpaging.

Important information for ASP.NET Core users

This library doesn't support ASP.NET Core. Visit https://github.com/joeaudette/cloudscribe.Web.Pagination for the logical successor of this library. Thanks Joe for the effort!

Usage (Razor / pseudo code):

@Html.Pager(pageSize, pageNumber, totalItemCount)

Options are added via the Options method:

@Html.Pager(pageSize, pageNumber, totalItemCount).Options(o => o
	.Action("action")
	.AddRouteValue("q", mySearchQuery)
)

Possible options:

Action(string action)
	Sets an alternative action for the pager that is different from the current action

Action(string action, string controller)
	Sets an alternative action and controller for the pager that is different from the current

AddRouteValue(string name, object value)
	Adds a single route value parameter that is added to page url's

AddRouteValueFor<TProperty>(Expression<Func<TModel, TProperty>> expression)
	Adds a strongly typed route value parameter based on the current model
	(e.g. AddRouteValueFor(m => m.SearchQuery))

RouteValues(object routeValues)
	Adds route value parameters that are added to the page url's

RouteValues(RouteValueDictionary routeValues)
	Adds route value parameters that are added to the page url's

DisplayTemplate(string displayTemplate)
	When set, the internal HTML rendering is bypassed and a DisplayTemplate view with the given
	name is rendered instead. Note that the DisplayTemplate must have a model of type PaginationModel.
	Instead of a template name, it's also possible to specify a complete template path, starting with ~/

MaxNrOfPages(int maxNrOfPages)
	Sets the maximum number of pages to show	

AlwaysAddFirstPageNumber
	By default we don't add the page number for page 1 because it results in canonical links. 
	Use this option to override this behaviour.	

PageRouteValueKey
	Set the page routeValue key for pagination links

DisplayFirstAndLastPage
	Displays first and last navigation pages

DisplayFirstPage
	Displays the first navigation page

DisplayLastPage
	Displays the last navigation page

SetFirstPageText
	Set a custom text for the first page

SetFirstPageTitle
	Set a custom text for title attribute of the first page link

SetLastPageText
	Set a custom text for the last page

SetLastPageTitle
	Set a custom text for title attribute of the last page link
	
SetPreviousPageText
	Set a custom text for the previous page

SetPreviousPageTitle
	Set a custom text for title attribute of the previous page link

SetNextPageText
	Set a custom text for the next page

SetNextPageTitle
	Set a custom text for title attribute of the next page link
	
UseItemCountAsPageCount
	The totalItemCount parameter is (ab)used for the total number of pages
	instead of the total number of items to facilitate backends that return the total number
	of pages instead of the total number of items

HidePreviousAndNextPage
	Don't show the 'previous' and 'next' links and only show the page numbers
	
CustomRouteName
	Indicate that a specific named route must be used when generating page links

HideFirstPageNumber
	Don't show page number 1 and '...' when navigating away

HideLastPageNumber
	Don't show the number of the last page and '...' when the last page is more than
	MaxNumberOfPages

PagedList

The library contains a PagedList class that makes it easy to work with paged data. Use it via an extension method on IEnumerable<> or IList<>:

myList.ToPagedList(pageIndex, pageSize)

with any unpaged list or

myList.ToPagedList(pageIndex, pageSize, totalItemCount)

when the list already only contains the data for the page

Contributing

Contributions via pull requests are great. We use 4 spaces for indentation :-).

More Repositories

1

moped

Web Client for Mopidy, built with AngularJS
JavaScript
419
star
2

VSReact

React/MobX TodoMVC app with ASP.NET Web Api backend, developed with Visual Studio
TypeScript
81
star
3

LeanAspNetCore-React

Lean ASP.NET 6.0 app that uses Razor Pages for server pages and React for part of the client application. Client-side build is done with Vite.
TypeScript
72
star
4

appoints-api-node

Appointment Scheduler Rest API build with Node.js.
JavaScript
71
star
5

RavenDBMembership

RavenDB ASP.NET membership provider with sample app
C#
55
star
6

MvcNotification

Sample ASP.NET MVC project that shows multiple ways for doing notifications, including AJAX scenario's.
C#
29
star
7

apptext

AppText is a content management system for applications. Application developers can use it to replace static resources in applications with dynamic content and delegate content management to non-developers.
C#
23
star
8

appoints-client

Appointment Scheduler app built with AngularJS
JavaScript
19
star
9

MinimalAspNetCore

Example minimal ASP.NET Core 2.0 MVC web app that leverages webpack and NPM for client assets.
C#
17
star
10

LeanAspNetCore

Lean ASP.NET Core 2.1 app that uses Razor Pages for server pages and npm and webpack for client assets.
C#
13
star
11

reverb-dealfinder

React Native + Redux example app (iOS + Android) for finding deals on the reverb.com marketplace.
JavaScript
12
star
12

aurelia-skeleton-webpack

Aurelia Skeleton app that uses webpack for loading, building and bundling instead of SystemJS/JSPM
JavaScript
11
star
13

AuthenticatedOwinIntegrationTests

Example Visual Studio 2015 solution for Owin Web API authenticated integration tests without authorization server
C#
9
star
14

aurelia-webpack-plugin

Webpack plugin that creates a custom webpack context for aurelia-loader-webpack
JavaScript
6
star
15

directus-booking

Directus example booking application
JavaScript
4
star
16

VSReact-Redux

React/Redux TodoMVC app with ASP.NET Web Api backend, developed with Visual Studio
JavaScript
2
star
17

netcore-auth

Example application that displays ways to perform authentication and authorization in ASP.NET Core
C#
1
star
18

blog

Astro
1
star
19

EF4-codeonly-demo

Demo application for Entity Framework 4 code-only
JavaScript
1
star