使用javascript自定义分页在mvc中溢出分页

时间:2016-08-24 07:28:33

标签: asp.net-mvc paging custompaging

在页面视图中编码我不好 check image pager me

控制器中的

代码

#region Paging List

var pageNum = (int)Session["PageNumber"];
double productCount = list.Count();
var pageTotal = Math.Round(productCount / pageSize);

if (pageTotal <= 1) 
    pageTotal = 1;

int skip = (pageNum - 1) * pageSize;
ViewBag.PageID = pageNum;
ViewBag.Count = productCount;
ViewBag.PageCount = pageSize;
ViewBag.PageTotal = pageTotal;
list = list.Skip(skip).Take(pageSize).ToList();

#endregion
视图中的

代码:

<div class="pagenavi">
  <a href="javascript:void(0)" onclick="GotoPageN(1)" class="pull-right">
    <i class="icon-perv-slide"></i> 
  </a>

@for (int i = 1; i <= (ViewBag.Count / ViewBag.PageCount) + 1; i++)
{
  <a href="javascript:void(0)" onclick="GotoPageN(@i)" class="@(((int)ViewBag.PageID == i) ? "current" : "")">@i</a>
}
  <a href="javascript:void(0)" onclick="GotoPageN(@(ViewBag.PageTotal))" class="pull-left"><i class="icon-next-slide"></i></a>
</div>
JavaScript中的

代码

function GotoPageN(pagenumber) {
  // $('html, body').animate({ scrollTop: 0 }, '500', 'swing');
  $('html,body').scrollTop(0);

  $("#divCategoryPartial").block({ message: "<img alt='' src='/Images/SiteImages/loaders/akalaz-logo.png' /> <img alt='' class='auto-style1' src='/Images/SiteImages/loaders/3d_2.gif' />" });
  $.ajax({
    url: "/ProductList/GotoPageN",
    type: "Get",
    data: { pagenumber: pagenumber }
  }).done(function (result) {
    $('#list').html(result);
    $("#divCategoryPartial").unblock();
  });

帮我编辑视图页面的代码 check image idea pager me

&LT; 12345 ... 34 35&gt;

分页视图

0 个答案:

没有答案