后台代码:

using Webdiyer.WebControls.Mvc;

 public ActionResult Index(int id = )
{
int pageIndex = id;
int count;
int pageSize = ; List<News> newsList =
newsSer.QueryByPage(pageIndex, pageSize, out count, c => c.IsDel == false && c.Status == (int)Enums.EStatus.pass, c => c.PTime)
.ToList(); ViewBag.count = Math.Ceiling(count * 1.0 / pageSize);
ViewBag.pageIndex = pageIndex;
ViewBag.newsList = newsList; PagedList<News> mPage = newsList.ToPagedList(pageIndex, pageSize);
mPage.TotalItemCount = count;
mPage.CurrentPageIndex = pageIndex;//此处3行可换为 IPagedList<News> mPage=new PagedList<News>(newsList,pageIndex,pageSize,count); ViewBag.mPage = mPage;
return View();
}

前台代码:

@using Webdiyer.WebControls.Mvc
@{
Layout = null;
List<News> newsList2 = ViewBag.newsList;
PagedList<News> mPage = ViewBag.mPage;
} @Html.Pager(mPage, new PagerOptions { PageIndexParameterName = "id", CurrentPagerItemTemplate = "<span class=\"current\">{0}</span>", DisabledPagerItemTemplate = "<span class=\"disabled\">{0}</span>", Id = "diggpager" })

样式:

 /*分页 楚晓冰*/
/* digg style*/
/* 蓝色:#000099 */
/* 淡蓝色:rgb(0, 160, 234) */ div#diggpager { padding-right: 3px; padding-left: 3px; padding-bottom: 3px; margin: 3px; padding-top: 3px; text-align: center; margin-top: 25px; }
div#diggpager a { border-right: #aaaadd 1px solid; padding-right: 5px; border-top: #aaaadd 1px solid; padding-left: 5px; padding-bottom: 2px; margin: 2px; border-left: #aaaadd 1px solid; color: rgb(0, 160, 234); padding-top: 2px; border-bottom: #aaaadd 1px solid; text-decoration: none; }
div#diggpager a:hover { border-right: rgb(0, 160, 234) 1px solid; border-top: rgb(0, 160, 234) 1px solid; border-left: rgb(0, 160, 234) 1px solid; color: #000; border-bottom: rgb(0, 160, 234) 1px solid; }
div#diggpager a:active { border-right: rgb(0, 160, 234) 1px solid; border-top: rgb(0, 160, 234) 1px solid; border-left: rgb(0, 160, 234) 1px solid; color: #000; border-bottom: rgb(0, 160, 234) 1px solid; }
div#diggpager span.current { border-right: rgb(0, 160, 234) 1px solid; padding-right: 5px; border-top: rgb(0, 160, 234) 1px solid; padding-left: 5px; font-weight: bold; padding-bottom: 2px; margin: 2px; border-left: rgb(0, 160, 234) 1px solid; color: #fff; padding-top: 2px; border-bottom: rgb(0, 160, 234) 1px solid; background-color: rgb(0, 160, 234); float: none !important; }
div#diggpager span.disabled { border-right: #eee 1px solid; padding-right: 5px; border-top: #eee 1px solid; padding-left: 5px; padding-bottom: 2px; margin: 2px; border-left: #eee 1px solid; color: #ddd; padding-top: 2px; border-bottom: #eee 1px solid; }

前台代码2:

@Html.Pager(mPage, new PagerOptions { PageIndexParameterName = "id", NumericPagerItemCount = 5, ContainerTagName = "ul", CssClass = "pagination", CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>", DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>", PagerItemTemplate = "<li>{0}</li>", Id = "bootstrappager2", PageIndexBoxId = "pageIndexBox", GoToButtonId = "goToBtn" })

样式用的是 bootstrap.css

备注:参考文档 http://www.webdiyer.com/mvcpager/demos/applycss/

MVC 分页的更多相关文章

  1. MVC分页

    http://www.cnblogs.com/iamlilinfeng/p/4075292.html 目录 一.Contrl与View数据传递(多表数据) 二.分页控件介绍 三.MVC源码说明 四.源 ...

  2. ASP.NET MVC分页组件MvcPager 2.0版发布暨网站全新改版

    MvcPager分页控件是在ASP.NET MVC Web应用程序中实现分页功能的一系列扩展方法,该分页控件的最初的实现方法借鉴了网上流行的部分源代码, 尤其是ScottGu的PagedList< ...

  3. ASP.NET MVC 4使用PagedList.Mvc分页

    ASP.NET MVC中进行分页的方式有多种,在NuGet上有提供使用PagedList.PagedList.Mvc进行分页. 1. 通过NuGet引用PagedList.Mvc 在安装引用Paged ...

  4. ASP.NET MVC分页实现之改进版-增加同一个视图可设置多个分页

    我之前就已经实现了ASP.NET MVC分页(查看该博文),但它有局限性,必须确保在同一个视图中只能有一处分页,若需要在同一个视图中设置多个分页,却无能为力,为此,我重新对原先的代码进行了优化,增加了 ...

  5. Mvc 分页栏扩展方法

    using System; using System.Collections.Generic; using System.Reflection; using System.Text; using Sy ...

  6. 转:MVC分页

    原文地址:http://www.cnblogs.com/iamlilinfeng/p/4075292.html 分页总是搞得我很烦,也是因为刚接触,貌似有好多插件,之前在用一个,可是后来发现一翻页原来 ...

  7. spring mvc 分页

    spring mvc 分页

  8. 基于Bootstrap的Asp.net Mvc 分页

    基于Bootstrap的Asp.net Mvc 分页的实现 最近写了一个mvc 的 分页,样式是基于 bootstrap 的 ,提供查询条件,不过可以自己写样式根据个人的喜好,以此分享一下.首先新建一 ...

  9. Mvc分页组件MvcSimplePager代码重构

    1 Mvc分页组件MvcSimplePager代码重构 1.1 Intro 1.2 MvcSimplePager 代码优化 1.3 MvcSimplePager 使用 1.4 End Mvc分页组件M ...

  10. Mvc分页组件MvcSimplePager代码重构及使用

    1 Mvc分页组件MvcSimplePager代码重构 1.1 Intro 1.2 MvcSimplePager 代码优化 1.3 MvcSimplePager 使用 1.4 End Mvc分页组件M ...

随机推荐

  1. Web 数据存储总结

    随着Web应用程序的出现,也产生了对于能够在客户端上存储用户信息能力的要求.这个问题的第一个解决方案是以cookie形似出现的.网景公司在一份名为“Persistent Client State: H ...

  2. 对Golang的一些看法

    原创文章转载请注明出处:@协思, http://zeeman.cnblogs.com   话说当今世界各种语言和伪语言群雄并起,连Rob Pike, Ken Thompson和Robert Gries ...

  3. Fix catalyst driver in Ubuntu 13.04 / 13.10

    Fix catalyst driver in Ubuntu 13.04 / 13.10(墙外文章备份) 1. Introduction I found lots of people strugglin ...

  4. ios UIButton设置单选效果,以及同时设置图片和标题

    一,设置单选效果 - (void)selectedBtnPress:(UIButton*)sender { //首先把原来按钮的选中效果消除 for (int i=0;i<num;i++) {/ ...

  5. Java程序员的日常—— 基于类的策略模式、List<?>与List、泛型编译警告、同比和环比

    早晨起得太早,昨晚睡得太晚,一天都迷迷糊糊的.中午虽然睡了半个小时,可是依然没有缓过来.整个下午都在混沌中....不过今天下载了一款手游--<剑侠情缘>,感觉不错,喜欢这种类型的游戏. 今 ...

  6. [Spring框架]Spring AOP基础入门总结二:Spring基于AspectJ的AOP的开发.

    前言: 在上一篇中: [Spring框架]Spring AOP基础入门总结一. 中 我们已经知道了一个Spring AOP程序是如何开发的, 在这里呢我们将基于AspectJ来进行AOP 的总结和学习 ...

  7. 遍历后台的List,让前台的多选宽被选中

    后端代码: /** * 获取优惠卷分页信息 * * * @param ph * 包括查询条件以及分页查询条件 * */ @Override public DataGrid<AppCmsCoupo ...

  8. PHP_01之PHP概述、数据、语法

    1.定义:PHP Hypertext Preprocessor,超文本预处理器,服务器端脚本语言:2.环境:WAMP:Window+Apache+PHP+MySQL: LAMP:Linux+Apach ...

  9. How Google Tests Software - The Life of a TE

    By James WhittakerThe Test Engineer is a newerrole within Google than either SWEs or SETs. As such, ...

  10. Ucos系统常用的数据结构有哪些?

    1)表 链表 表中主要了解链表,尤其是单向链表. 2)数组 一维数组 二维数组 使用数组有什么好处,在c语言中,数组是一组连续数字的集合它们数组的下标,代表了数组的相对位置,所以说,在一些高效的查表过 ...