AspMvc5Pagination

This is a single dll class library that will enable you to add paging your asp mvc project. Download the pagination.dll (go to download section) and add this to your project reference and wala you are done.

import the dll in your views

@using ExicoSoftwareSolutions.WebTools.MvcPagination

And suppose your controller passes the model to the view as below

public class ProductsViewModel{
  public int TotalItem;
  public int ItemsPerPage;
  public Icollection<Products> ps;
.....
}

now in the view you can actually do something like this

@Html.RenderPaging(Model.TotalItem, Model.ItemsPerPage, new PagerOptions() { WrapperDivClass ="mypagination" });


*Note that any query string will be automatically added to the page numbered links , so that you do not have to worry about manually adding the query string segments to the pagination links.

This helper has a lot of customization options that you can configure while rendering the paging.

Here is the page option object you can pass to the page renderer -

public class PagerOptions
    {
        public string  NextText { get; set; }//the text for the next link
        public string  PrevText { get; set; }//text for the previous link
        public string  FirstText { get; set; }//text for the first link
        public string  LastText { get; set; }//text for the first link
        public string  WrapperDivClass { get; set; }//the class name for the div that sorrounds the links
        public Boolean ShowFirstAndLast { get; set; }//toggle on and off displaying the "First" and "Last" link
        public Boolean ShowNextAndPrev { get; set; }//toggle on and off displaying the "Prev" and "Next" link
        public string  Controller { get; set; }//if a controller is specified
        public string  Action { get; set; }//if an action is specified
        public string  PageParam { get; set; }//the page url param default is "page"  
        public Boolean ShowEvenOnlyOnePage { get; set; }//render the pager even if there is only one page
        public int NumberOfPagesToDisplay { get; set; } // the number of page links that will be shown on a page
...................
}

Last edited Apr 8, 2014 at 4:10 PM by ronnie_nsu, version 19