zoukankan      html  css  js  c++  java
  • 分页

    <div>
    @{
    var pageTotal = Convert.ToInt32(Request["pageTotal"]);
    var toolName = "tool.Paging";
    if (ViewData["toolName"] != null)
    {
    toolName = ViewData["toolName"] + "";
    }
    if (ViewData["pageTotal"] != null)
    {
    pageTotal = Convert.ToInt32(ViewData["pageTotal"]);
    }
    var currentPageIndex = Convert.ToInt32(Request["currentPageIndex"]);

    if (pageTotal <= 1)
    {
    pageTotal = 1;
    }
    if (currentPageIndex <= 1)
    {
    currentPageIndex = 1;
    }
    if (currentPageIndex >= pageTotal)
    {
    currentPageIndex = pageTotal;
    }
    var startPage = currentPageIndex - 2 >= 1 ? currentPageIndex - 2 : 1;
    var endPage = currentPageIndex + 2 <= pageTotal ? currentPageIndex + 2 : pageTotal;
    if (currentPageIndex + 2 > pageTotal) { startPage = pageTotal - 4 >= 1 ? pageTotal - 4 : 1; }
    if (currentPageIndex - 2 <= 1) { endPage = startPage + 4 >= pageTotal ? pageTotal : startPage + 4; }

    var nextPageIndex = currentPageIndex >= pageTotal ? currentPageIndex : currentPageIndex + 1;
    <ul class="pagination pull-right" style="margin: 0; font-size: 12px;">
    <li><a href="javascript:@(toolName)(1)">首页</a></li>
    <li><a href="javascript:@(toolName)(@(currentPageIndex - 1 < 1 ? 1 : currentPageIndex - 1))">上一页</a></li>
    @for (var i = startPage; i <= endPage; i++)
    {
    <li class="@(currentPageIndex == i ? "active" : "")"><a href="javascript:@(toolName)(@(i))">@(i)</a></li>
    }
    <li><a href="javascript:@toolName (@nextPageIndex)">下一页</a></li>
    <li><a href="javascript:@toolName (@pageTotal)">尾页</a></li>
    <li class="disabled"><a href="javascript:void(0)">第@(currentPageIndex)/@(pageTotal)页</a></li>
    </ul>
    }
    <div style="clear: both;"></div>
    </div>

  • 相关阅读:
    Django框架---- 信号
    算法----迷宫问题
    算法----数据结构
    算法----其他排序
    Twisted简介
    爬虫----selenium模块
    爬虫----Scrapy框架
    爬虫----requests模块
    关于电脑运行ubunut出现严重发热的问题
    基本操作命令详解
  • 原文地址:https://www.cnblogs.com/jooucks/p/7048592.html
Copyright © 2011-2022 走看看