zoukankan      html  css  js  c++  java
  • 上一页 1 2 ...10 下一页 百度 GOOGLE 分页

    PageSet.ascs HTML :
    <table>
    <tr>
       <td id="p" runat="server"><FONT face="宋体"></FONT></td>
    </tr>
    </table>

    PageSet.ascs .cs :

    /// <summary>
    /// PageSet 百度分页 Asp.NET @ 一网情深 QQ: 757015000
    /// </summary>
    public class PageSet : System.Web.UI.UserControl
    {
       protected System.Web.UI.HtmlControls.HtmlTableCell p=new HtmlTableCell();

       public int TotalNum; // 一共有多少条数据
       public int PageSize; // 每页显示多少条数据
        public string PageName; //转发页面的名称
       public int TotalPage; // 总共页数
       public string PageUrl; //转发路径
       public int PageGroup; //每多少个页面为一组

       public void PageS(int pSize,int tNum,string pName,int pGroup)
       {
        this.PageSize=pSize;
        this.TotalNum=tNum;
        this.PageName=pName;
        this.PageGroup=pGroup;

        if((TotalNum%PageSize)==0)
        {
         TotalPage=TotalNum/PageSize;
        }
        else
        {
         TotalPage=TotalNum/PageSize +1;
        }
        if(PageName.IndexOf("?")>0)
        {
         PageUrl=PageName + "&";
        }
        else
        {
         PageUrl=PageName + "?";
        }
       }
       public string Installize(int CurPage)
       {   
        int pstart=0; //起始页
        int plast=0; //终点页
      
        bool pri=false; //上一页
        bool next=true; //下一页

        int sx=CurPage+1;
        int sxn=CurPage-1;

        string strpri="<a href=" + PageUrl + "Page=" + sxn.ToString() + "><FONT color=blue>上一页</font></a>&nbsp;";
        string strnext="<a href=" + PageUrl + "Page=" + sx.ToString() + "><FONT color=blue>下一页</font></a>&nbsp;";

        //确定起始页与终点页
        if(CurPage==1)
        {
         if(TotalPage<=PageGroup)
         {
          pstart=1;plast=TotalPage;    
         }
         else
         {
          pstart=1;plast=PageGroup;     
         }
        }
        else  
        {    
         if(CurPage <=PageGroup+1)
         {
          pstart=1;
         }
         else
         {
          pstart=CurPage-PageGroup;
         }

         if(CurPage<=TotalPage+1-PageGroup)
         {
          plast=CurPage+PageGroup-1;
         }
         else
         {
          plast=TotalPage;
          next=false;
         }
         pri=true;
       
        }

        if(pri==false)
        {
         strpri="";
        }
        if(next==false)
        {
         strnext="";
        }
        string g="";
        for(int i=pstart;i<=plast;i++)
        {
         if(CurPage==i)
         {
          g+= i.ToString() +"&nbsp;";
         }
         else
         {
          g+= "<a href=" + PageUrl + "Page=" + i.ToString() + "><FONT color=blue>[" +i.ToString() +"]</font></a>&nbsp;";
         }
        }  
                 return strpri+g+strnext;
       }
    }
    }
    测试页面 :
    HTML:
    <table>
    <tr>
       <td id="p" runat="server"><FONT face="宋体"></FONT></td>
    </tr>
    </table>
    .CS:
    if(Request.QueryString["Page"]!=null)
        {
         ps.PageS(30,1000,"ssjg.aspx",5);
         p.InnerHtml=ps.Installize(Int32.Parse(Request.QueryString["Page"]));

        }
        else
        {
         ps.PageS(30,1000,"ssjg.aspx",5);
         p.InnerHtml=ps.Installize(1);
        }

  • 相关阅读:
    hihocoder 1049 后序遍历
    hihocoder 1310 岛屿
    Leetcode 63. Unique Paths II
    Leetcode 62. Unique Paths
    Leetcode 70. Climbing Stairs
    poj 3544 Journey with Pigs
    Leetcode 338. Counting Bits
    Leetcode 136. Single Number
    Leetcode 342. Power of Four
    Leetcode 299. Bulls and Cows
  • 原文地址:https://www.cnblogs.com/jcomet/p/1242825.html
Copyright © 2011-2022 走看看