GithubHelp home page GithubHelp logo

amexn / mvcpaging Goto Github PK

View Code? Open in Web Editor NEW

This project forked from martijnboland/mvcpaging

0.0 1.0 0.0 2.58 MB

ASP.NET MVC Paging HTML helper

Home Page: http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/

License: MIT License

mvcpaging's Introduction

The MvcPaging library contains an ASP.NET MVC HTML helper that renders a pager based on given parameters.

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

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

	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

	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

--------------------------------------------------------------------------------------------------------

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

--------------------------------------------------------------------------------------------------------

For the source and a demo project, see https://github.com/martijnboland/MvcPaging. 
We accept contributions via GitHub pull requests. Please use tabs for indentation and turn off autocrlf.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.