首页 > 解决方案 > 没有样式的 ASP Net MVC pagedlistpager

问题描述

我安装了 PagedList.Mvc 和 PagedList 但是当我使用它时我根本没有样式:

没有任何样式的 pagedListPager 的图像

我的控制器看起来像这样:

public ActionResult CarrosList(string search, int? i)
{
    return View(db.Carro.Where(x=>x.Estado != "Vendido" && x.Titulo.StartsWith(search) || search == null).ToList().ToPagedList(i ?? 1, 6));
}

我的 cshtml 页面如下所示:

@Html.PagedListPager(Model, i => Url.Action("CarrosList", new { i, search = Request.QueryString["search"]}))

标签: c#htmlcssasp.netasp.net-mvc

解决方案


您显示的代码处理服务器端分页并呈现 HTML。

然而,样式都与 CSS 样式表有关。

来自https://github.com/TroyGoode/PagedList

<!-- import the included stylesheet for some (very basic) default styling -->
<link href="/Content/PagedList.css" rel="stylesheet" type="text/css" />

基本上确保包含样式表。

明白了

仅当您首次添加 nuget 包时,才会安装 Content 文件夹中的内容。因此,如果其他人安装了该软件包并且没有将相关的 CSS 文件添加到源代码管理中,则它可能会丢失。您可能需要删除并重新添加 nuget 包进行修复。


推荐阅读