Fork me on GitHub

MvcPager demo - Pager items templates

This sample demonstrates how to apply html template to pager items.

NumericPagerItemTemplate = "<strong>{0}</strong>",CurrentPagerItemTemplate = "<span class=\"text-danger\">{0}</span>"

PagerItemTemplate = "{0}&nbsp;"
First Prev 1 2 3 4 5 6 7 8 9 10 ... Next Last 

CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>", DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>", PagerItemTemplate = "<li>{0}</li>"

View:

@model PagedList<string>
@Html.Pager(Model, new PagerOptions { PageIndexParameterName = "id", NumericPagerItemTemplate = "<strong>{0}</strong>",CurrentPagerItemTemplate = "<span class=\"text-danger\">{0}</span>",DisabledPagerItemTemplate = "<span style=\"color:gray\">{0}</span>"})
<hr/>
@Html.Pager(Model, new PagerOptions { PageIndexParameterName = "id", PagerItemTemplate = "{0} " })
<hr />
@Html.Pager(Model, new PagerOptions { PageIndexParameterName = "id", ContainerTagName = "ul", CssClass = "pagination", CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>", DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>", PagerItemTemplate = "<li>{0}</li>"})

Controller:

        
        public ActionResult PagerItemsTemplate(int id = 1)
        {
            return View(new PagedList<string>(new string[0], id, 1, 80));
        }