MVC paging and mvc Paging
Background code:
Using Webdiyer. WebControls. Mvc;
1 public ActionResult Index(int id = 1) 2 { 3 int pageIndex = id; 4 int count; 5 int pageSize = 7; 6 7 List<News> newsList = 8 newsSer.QueryByPage(pageIndex, pageSize, out count, c => c.IsDel == false && c.Status == (int)Enums.EStatus.pass, c => c.PTime) 9 .ToList();10 11 ViewBag.count = Math.Ceiling(count * 1.0 / pageSize);12 ViewBag.pageIndex = pageIndex;13 ViewBag.newsList = newsList;14 15 PagedList<News> mPage = newsList.ToPagedList(pageIndex, pageSize);16 mPage.TotalItemCount = count;17 mPage.CurrentPageIndex = pageIndex;18 19 ViewBag.mPage = mPage;20 return View();21 }
Front-end code:
@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" })
Style:
1/* Paging Chu xiaobin */2/* digg style */3/* Blue: #000099 */4/* Light blue: rgb (0,160,234) */5 6 div # diggpager {padding-right: 3px; padding-left: 3px; padding-bottom: 3px; margin: 3px; padding-top: 3px; text-align: center; margin-top: 25px;} 7 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;} 8 div # diggpager: 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;} 9 div # diggpager a: active {border-right: rgb (0,160,234) 1px solid; bord Er-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 ;} 10 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; paddin G-top: 2px; border-bottom: rgb (0,160,234) 1px solid; background-color: rgb (0,160,234); float: none! Important;} 11 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 ;}
Note: Reference Document http://www.webdiyer.com/mvcpager/demos/applycss/