Fork me on GitHub

PagerOptions.PageNumberFormatString property

Gets or sets the format string for all numeric pager items.

Remarks:

If CurrentPageNumberFormatString property value is not set, this format string will also applied to the current page pager item.

Syntax:

public string PageNumberFormatString {get; set;}

Default value:

{0}

Example:

@Html.Pager(Model,new PagerOptions{PageNumberFormatString="-{0}-"})

This property value can also be set via the Options method as bellow:

HtmlPager:

@Html.Pager(Model).Options(o=>o.SetPageNumberFormatString("-{0}-"))

AjaxPager:

@Ajax.Pager(Model).Options(o=>o.SetPageNumberFormatString("-{0}-")).AjaxOptions(a=>a.SetUpdateTargetId("target"))

Live demo:

@Html.Pager(Model, new PagerOptions { PageNumberFormatString = "-{0}-" })
FirstPrev-1--2--3--4--5--6--7--8--9--10-...NextLast

@Html.Pager(Model).Options(o=>o.SetPageNumberFormatString("【{0}】").SetCurrentPageNumberFormatString("{0}")
FirstPrev1【2】【3】【4】【5】【6】【7】【8】【9】【10】...NextLast