我有一个htmlhelper扩展方法,如下所示。它返回的实例
PagedList.Mvc.HtmlHelper.PagedListPager
.
pagedListrenderOptions指定了一些CSS类。使用此方法的每个视图都需要添加一个指向包含样式的CSS文件的链接。我发现这是重复和多余的。
是否可以将CSS添加到将在此处返回的mvchtmlstring实例中?
public static MvcHtmlString PagedListPagerCustom(this HtmlHelper helper, UrlHelper Url, PagedList.IPagedList pager)
{
return PagedList.Mvc.HtmlHelper.PagedListPager(
helper,
pager,
page =>
{
return Url.Action("Inspection", "Operation", new { page = page, pageList = true });
},
new PagedList.Mvc.PagedListRenderOptions()
{
LiElementClasses = new List<string> { "pagerLiElement" },
ContainerDivClasses = new List<string> { },
UlElementClasses = new List<string> { "pagerUlElementClasses" },
DisplayPageCountAndCurrentLocation = false,
DisplayLinkToFirstPage = PagedList.Mvc.PagedListDisplayMode.Always,
DisplayLinkToLastPage = PagedList.Mvc.PagedListDisplayMode.Always,
DisplayLinkToNextPage = PagedList.Mvc.PagedListDisplayMode.Always,
DisplayLinkToPreviousPage = PagedList.Mvc.PagedListDisplayMode.Always,
Display = PagedList.Mvc.PagedListDisplayMode.IfNeeded,
LinkToLastPageFormat = "Last",
LinkToNextPageFormat = "Next",
LinkToPreviousPageFormat = "Prev",
LinkToFirstPageFormat = "1st",
DisplayEllipsesWhenNotShowingAllPageNumbers = true,
MaximumPageNumbersToDisplay = 5,
DisplayLinkToIndividualPages = true,
ClassToApplyToFirstListItemInPager = "pagerLiElementFirst",
ClassToApplyToLastListItemInPager = "pagerLiElement",
}
);
}
我要添加的CSS链接是:
<link href="~/Content/css/PageListCustom.css" rel="stylesheet">