• 利用AspNetPager进行文章内分页(用ckeditor分页符进行分页)


    aspx:

    <%if (YesIsNoPage)
    {%>
          <webdiyer:AspNetPager ID="AspNetPager" CssClass="paginator" CurrentPageButtonClass="cpb"
          runat="server" AlwaysShow="True" FirstPageText="Home" LastPageText="End" NextPageText="Next"
          PageSize="1" PrevPageText="Previous" OnPageChanged="AspNetPager_PageChanged"
          CustomInfoTextAlign="Center" LayoutType="Table" ShowPageIndex="false" CustomInfoHTML="Current:                                                    %CurrentPageIndex%/%PageCount% Pages"
          PageIndexBoxType="TextBox" ShowCustomInfoSection="Left" ShowPageIndexBox="Never">
          </webdiyer:AspNetPager>
    <% } %>

    cs:

    protected static string ProductsText;
    protected static bool YesIsNoPage;
    protected static string strContent;
    protected void Products_load()
    {
                string text = ProductsText;
                //查找分页符并替换html标签    
                  string StringB = "<div style=\"page-break-after: always;\"> <span style=\"display: none;\">&nbsp;</span></div> ";
                text = text.Replace("\n\t", "");
                text = text.Replace("\n", "<br />");
                text = text.Replace("\r", " ");
                string[] strLined = text.Split(new string[] { StringB }, StringSplitOptions.RemoveEmptyEntries);
                string tempString = null;
                this.AspNetPager.RecordCount = strLined.Length;
                int PageSize = this.AspNetPager.PageSize;
                int PageIndex = this.AspNetPager.CurrentPageIndex;
                //判断是否显示分页控件
                  if (strLined.Length > 1)
                    YesIsNoPage = true;
                else
                    YesIsNoPage = false;
                //判断是否启动分页
                  int JudgeYesPage = strLined.Length / PageSize + 1;
                int JudgeNoPage = strLined.Length;
                if (this.AspNetPager.CurrentPageIndex != JudgeYesPage)
                {
                    for (int i = (PageIndex - 1) * PageSize; i < PageSize * PageIndex; i++)
                    {
                        tempString += strLined[i] + "<br />";
                    }
                    strContent = tempString;
                }
                else
                {
                    for (int i = (PageIndex - 1) * PageSize; i < JudgeNoPage; i++)
                    {
                        tempString += strLined[i] + "<br />";
                    }
                    strContent = tempString;
                }
    } 
     protected void AspNetPager_PageChanged(object sender, EventArgs e)
     {
                Products_load();
     }
  • 相关阅读:
    Nginx目录结构与配置文件详解
    最新Sql语句来啦
    一个小工具帮你搞定实时监控Nginx服务器
    javascript学习笔记基于对象续
    Buffer解析
    使用用户自定义控件实现asp.net的的权限管理
    asp.net java 的十大关键技术
    程序员的基本素质
    无法编译的异常解决
    程序员的健康作息时间 该看看啊
  • 原文地址:https://www.cnblogs.com/Setme/p/2537090.html
Copyright © 2020-2023  润新知