zoukankan      html  css  js  c++  java
  • .NET MVC 视图页面自定义分页

    @if (Model.commentList != null && Model.commentList.Count != 0)
                            {
                                string url = string.Empty;
                                int pageCount = Model.CommentRecordCount % Model.PageSize > 0 ? (Model.CommentRecordCount / Model.PageSize) + 1 : Model.CommentRecordCount / Model.PageSize;
                                int currentPageTmp = 0;
    
                                //上一页
                                if (Model.PageCurrentIndex != 1)
                                {
                                    currentPageTmp = Model.PageCurrentIndex - 1;
                                    url = "/hotel_review-d" + Model.CityID + "-s" + Model.HotelId + "-pi-" + currentPageTmp + ".html#review";
                                <a href="@url">&lt;&lt;</a>
                                }
    
                                //首页
                                if (Model.PageCurrentIndex == 1)
                                {
                                <text><em>1</em></text>
                                }
                                else
                                {
                                    url = "/hotel_review-d" + Model.CityID + "-s" + Model.HotelId + "-pi-" + 1 + ".html#review";
                                <a href="@url">1</a>
                                }
    
                                //当前页左部
                                currentPageTmp = Model.PageCurrentIndex - 2;
                                if (currentPageTmp == 1)
                                {
                                    currentPageTmp++;
                                }
                                //左部省略号( 跨度超过3就显示省略号)
                                if (Model.PageCurrentIndex - 1 > 3)
                                {
                                <text>…</text>
                                }
                                //左部页码( 显示当前页之前两页(不包括第一页))
                                while (currentPageTmp > 1 && currentPageTmp < Model.PageCurrentIndex )
                                {
                                    url = "/hotel_review-d" + Model.CityID + "-s" + Model.HotelId + "-pi-" + currentPageTmp + ".html#review";
                                <a href="@url">@currentPageTmp</a>
                                    currentPageTmp++;
                                }
    
                                //当前页
                                if (Model.PageCurrentIndex != 1 && Model.PageCurrentIndex != pageCount)
                                {
                                <text><em>@Model.PageCurrentIndex </em></text>
                                }
    
                                //当前页右部(不包括当前页)
                                int forewordCount = 2;
                                currentPageTmp = Model.PageCurrentIndex + 1;
                                //右部页面(不显示当前页,不包括最后一页)
                                while (currentPageTmp < pageCount && forewordCount > 0)
                                {
    
                                    url = "/hotel_review-d" + Model.CityID + "-s" + Model.HotelId + "-pi-" + currentPageTmp + ".html#review";
                                <a href="@url">@currentPageTmp</a>
                                    currentPageTmp++;
                                    forewordCount--;
                                }
                                //右部省略号(跨度超过3就显示省略号)
                                if (pageCount - Model.PageCurrentIndex > 3)
                                {
                                <text>…</text>
                                }
    
                                //尾页
                                if (Model.PageCurrentIndex == pageCount)
                                {
                                <text><em>@pageCount</em></text>
                                }
                                else
                                {
                                    url = "/hotel_review-d" + Model.CityID + "-s" + Model.HotelId + "-pi-" + pageCount + ".html#review";
                                <a href="@url">@pageCount</a>
                                }
    
                                //下一页
                                if (Model.PageCurrentIndex != pageCount)
                                {
                                    currentPageTmp = Model.PageCurrentIndex + 1;
                                    url = "/hotel_review-d" + Model.CityID + "-s" + Model.HotelId + "-pi-" + currentPageTmp + ".html#review";
                                <a href="@url">&gt;&gt;</a>
                                }
                            }
  • 相关阅读:
    看了一下unity5.6的新功能 以及Timeline
    摄像机旋转约束问题及解决
    MeshCollider双面化脚本
    js模块化历程
    用“MEAN”技术栈开发web应用(一)AngularJs前端架构
    简单一招实现json数据可视化
    基于zepto的移动端日期+时间选择插件
    我们的创业项目是如何夭折的
    前端资源预加载并展示进度条
    轻量级移动端日期选择器
  • 原文地址:https://www.cnblogs.com/wuMing-dj/p/3798974.html
Copyright © 2011-2022 走看看