• 分页


    <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>

  • 相关阅读:
    MySQL-02 数据表管理
    MySQL-01 MySQL数据库安装指南
    Linux-04 Linux中Tomcat和MySQL的安装
    Linux-03 Linux下的tar命令
    Linux-02 Linux常用命令
    Linux-01 虚拟机Linux的安装
    从服务器下载图片
    WPF Radio组的绑定
    使用缓存的9大误区(下)转载
    使用缓存的9大误区(上)转载
  • 原文地址:https://www.cnblogs.com/jooucks/p/7048592.html
Copyright © 2020-2023  润新知