栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C# > C#教程

BootStrap mvcpager分页样式(get请求,刷新页面)

C#教程 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

BootStrap mvcpager分页样式(get请求,刷新页面)

使用方法:

先把mvcpager.dll引用加入mvc项目中。

前台代码

前台:

@{
Layout = null;
}
@using Webdiyer.WebControls.Mvc
@model PagedList




Index




@foreach (var item in Model)
{
@item
} @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "pageIndex", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "
  • {0}
  • ", PagerItemWrapperFormatString = "
  • {0}
  • " }, new { id = "bootstrappager", @class = "pagination" })

    后台代码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Webdiyer.WebControls.Mvc;
    namespace MvcApplication6.Controllers
    {
    public class HomeController : Controller
    {
    //
    // GET: /Home/
    public ActionResult Index(int pageIndex=1, int pageSize=2)
    {
    List list = new List(){
    "a",
    "b",
    "c",
    "d"
    };
    return View(list.ToPagedList(pageIndex, pageSize));
    }
    }
    } 
    @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "pageIndex", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "
  • {0}
  • ", PagerItemWrapperFormatString = "
  • {0}
  • " }, new { id = "bootstrappager", @class = "pagination" })

    样式更改:class为pager或pagination

    如图:

    样式文件:

    .pagination {
    border-radius: 4px;
    display: inline-block;
    margin: 20px 0;
    padding-left: 0;
    }
    .pagination > li {
    display: inline;
    }
    .pagination > li > a, .pagination > li > span {
    background-color: #fff;
    border: 1px solid #ddd;
    color: #337ab7;
    float: left;
    line-height: 1.42857;
    margin-left: -1px;
    padding: 6px 12px;
    position: relative;
    text-decoration: none;
    }
    .pagination > li:first-child > a, .pagination > li:first-child > span {
    border-bottom-left-radius: 4px;
    border-top-left-radius: 4px;
    margin-left: 0;
    }
    .pagination > li:last-child > a, .pagination > li:last-child > span {
    border-bottom-right-radius: 4px;
    border-top-right-radius: 4px;
    }
    .pagination > li > a:hover, .pagination > li > span:hover, .pagination > li > a:focus, .pagination > li > span:focus {
    background-color: #eee;
    border-color: #ddd;
    color: #23527c;
    z-index: 3;
    }
    .pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover, .pagination > .active > span:hover, .pagination > .active > a:focus, .pagination > .active > span:focus {
    background-color: #337ab7;
    border-color: #337ab7;
    color: #fff;
    cursor: default;
    z-index: 2;
    }
    .pagination > .disabled > span, .pagination > .disabled > span:hover, .pagination > .disabled > span:focus, .pagination > .disabled > a, .pagination > .disabled > a:hover, .pagination > .disabled > a:focus {
    background-color: #fff;
    border-color: #ddd;
    color: #777;
    cursor: not-allowed;
    }
    
    .pager {
    list-style: outside none none;
    margin: 20px 0;
    padding-left: 0;
    text-align: center;
    }
    .pager li {
    display: inline;
    }
    .pager li > a, .pager li > span {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 15px;
    display: inline-block;
    padding: 5px 14px;
    text-decoration: none;
    }
    .pager li > a:hover, .pager li > a:focus {
    background-color: #eee;
    text-decoration: none;
    }
    .pager .next > a, .pager .next > span {
    float: right;
    }
    .pager .previous > a, .pager .previous > span {
    float: left;
    }
    .pager .disabled > a, .pager .disabled > a:hover, .pager .disabled > a:focus, .pager .disabled > span {
    background-color: #fff;
    color: #777;
    cursor: not-allowed;
    }
    .pager > .active > a, .pager > .active > span, .pager > .active > a:hover, .pager > .active > span:hover, .pager > .active > a:focus, .pager > .active > span:focus {
    background-color: #eee;
    cursor: default;
    z-index: 2;
    }

    以上所述是小编给大家介绍的BootStrap mvcpager分页样式(get请求,刷新页面),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对考高分网网站的支持!

    转载请注明:文章转载自 www.mshxw.com
    本文地址:https://www.mshxw.com/it/124075.html
    我们一直用心在做
    关于我们 文章归档 网站地图 联系我们

    版权所有 (c)2021-2022 MSHXW.COM

    ICP备案号:晋ICP备2021003244-6号