后台代码:

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. dijit样式定制(二)dijit.form.Select与dijit.form.NumberSpinner

    dijit.form.Select: Select的样式位于Claro/form/Select.less中,Select主要通过table来布局,下图可以看到Select的布局结构 介绍几个主要的cl ...

  2. 在.net中使用aquiles访问Cassandra(三)

    之前我们实现了如何修改数据,还需要相应的删除动作.删除方式会有几种情况,以下分别一一介绍.   1.批量删除,适应于多行多列的情况. public void Remove(string columnF ...

  3. Technical news July-11

    http://blog.jobbole.com/73300/ 对比Ruby和Python的垃圾回收(2):代式垃圾回收机制 http://www.microsoftvirtualacademy.com ...

  4. MYSQL 大文件无法导入的问题。

    1. 设置maxpacket. 要在[mysqld]标签下.这个疏忽了,就会发现没效果. 基本网上的都没说清,要看stackoverflow. Change in the my.ini file. I ...

  5. redis系列-redis的使用场景

    redis越来越受大家欢迎,提升下速度,做下缓存,完成KPI之利器呀.翻译一篇文章<<How to take advantage of Redis just adding it to yo ...

  6. linux网络编程系列-网络连接的建立

    一个比较实用的连接函数,支持host为域名. #include <netdb.h> #include <sys/socket.h> #include <sys/types ...

  7. Atitit 图像处理--图像分类 模式识别 肤色检测识别原理 与attilax的实践总结

    Atitit 图像处理--图像分类 模式识别 肤色检测识别原理 与attilax的实践总结 1.1. 五中滤镜的分别效果..1 1.2. 基于肤色的图片分类1 1.3. 性能提升2 1.4. --co ...

  8. 8 步搭建 Node.js + MongoDB 项目的自动化持续集成

    任何事情超过 90 秒就应该自动化,这是程序员的终极打开方式.Automating shapes smarter future. 这篇文章中,我们通过创建一个 Node.js + MongoDB 项目 ...

  9. fir.im Weekly - 如何打造真正的工程师文化

    好的工程师,无法忍受低效且无趣的工作.优秀的技术团队应该自上而下的地推进技术平台化建设.DevOps.自动化构建.测试和部署流程,积极采用合适的第三方工具或创造工具,进行周期性的前沿技术分享等等. 先 ...

  10. FreeMarker 学习

    一.FreeMarker FreeMarker是一款模板引擎: 即一种基于模板和要改变的数据, 并用来生成输出文本(HTML网页.电子邮件.配置文件.源代码等)的通用工具. 它不是面向最终用户的,而是 ...