父视图:
var pagingModel = new Watchlist_Web.Models.ViewModel.PagingPartialViewModel();
pagingModel.PagedList = Model;
pagingModel.UrlAction = "AdminIndex";
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("query", Request.QueryString["query"]);
parameters.Add("modelClass", Request.QueryString["nodeClassId"]);
pagingModel.RouteValues = new RouteValueDictionary(parameters);
pagingModel.ContainerDivClasses = "pagination-sm col-md-5";
@Html.Partial("_PagingPartial", pagingModel)
局部视图:
@using PagedList;
@using PagedList.Mvc;
@model Watchlist_Web.Models.ViewModel.PagingPartialViewModel
@Html.PagedListPager(Model.PagedList, page => Url.Action(Model.UrlAction,
new RouteValueDictionary(new { page = page })),
new PagedListRenderOptions()
{
DisplayPageCountAndCurrentLocation = true,
DisplayLinkToFirstPage = PagedListDisplayMode.IfNeeded,
DisplayLinkToLastPage = PagedListDisplayMode.IfNeeded,
ContainerDivClasses = new[] { Model.ContainerDivClasses }
})
我正在尝试将 Model.RouteValues 添加到 PagedListPager 的部分视图的 HTML 帮助程序中。URL.Action 的第二个参数是我需要指定路由值的地方,并且只有“页面”效果很好。但是,我正在尝试找到一种将 Model.RouteValues 的键/值对添加到此参数的方法。