在MVC3中使用“OnlyShowFivePagesAtATime”时如何更改pagedlist的链接名称?

时间:2013-02-12 07:23:37

标签: asp.net-mvc-3

大家好我正在尝试更改名称“LinkToFirstPageFormat”或“LinkToPreviousPageFormat”并尝试使用“OnlyShowFivePagesAtATime”

这是我的PagedListPager

@Html.PagedListPager(Model.video, page => Url.Action("video_play", new { page = page }), new PagedListRenderOptions { LinkToFirstPageFormat = "<< Next", LinkToPreviousPageFormat = "<", LinkToNextPageFormat = ">", LinkToLastPageFormat = "Last >>" })

此时此刻还好,但是当我在这里尝试使用渲染选项的“OnlyShowFivePagesAtATime”属性时,你可以在下面看到我得到“没有重载方法PagedlistPager需要4个参数”

@Html.PagedListPager(Model.video, page => Url.Action("video_play", new { page = page }), new PagedListRenderOptions { LinkToFirstPageFormat = "<< Next", LinkToPreviousPageFormat = "<", LinkToNextPageFormat = ">", LinkToLastPageFormat = "Last >>" },PagedListRenderOptions.OnlyShowFivePagesAtATime)

那么如何使用PagedListRenderOptions.OnlyShowFivePagesAtATime更改链接名称?

1 个答案:

答案 0 :(得分:5)

好吧我找到了解决方案,如果有人遇到同样的问题你可以使用“MaximumPageNumbersToDisplay = 5”属性,如下所示

@Html.PagedListPager(Model.video, page => Url.Action("video_play", new { page = page }), new PagedListRenderOptions { LinkToFirstPageFormat = String.Format("<< Next"), LinkToPreviousPageFormat = String.Format("<"), LinkToNextPageFormat = String.Format(">"), LinkToLastPageFormat = String.Format("Last >>"),MaximumPageNumbersToDisplay=5 })