• 分页控件(.ascx文件)


    <script>        
            
    var strURL='<%=strURL%>';
            
    var recordNum=<%=recordNum%>;
            
    var perPageNum=<%=perPageNum%>;
            
    var currentPage=<%=pageIndex%>;
            
    var p=<%=pageIndex%>-1;
            
    var fontcolor='<%=fontcolor%>';
            
            
    if(recordNum%perPageNum==0
            {
                pageNum
    =recordNum/perPageNum;
            }
            
    else
            {
                pageNum
    =(recordNum-recordNum%perPageNum)/perPageNum+1;
            }
            document.write('
    <table border="0" cellpadding="0" cellspacing="3" width="<%=tableWidth%>" align="center" >');
            document.write('
    <form method=post action="'+strURL+'">');        
            document.write('
    <tr style="font-size: 12px;"><td valign="middle">');
            document.write('页次:
    <b>'+currentPage+</b>/<b> '+pageNum+ '</b>页 每页<b>'+perPageNum+</b> 共计:<b>   '+recordNum+</b>条数据</td>');
            document.write('
    <td valign="middle"><div align="right" >分页:');
            
    if(currentPage==1)
            {
                document.write('
    <font face=webdings color="'+fontcolor+'">9</font>');
            }
            
    else
            {
                document.write('
    <a href="'+strURL+'?page=1" title="首页"><font face=webdings>9</font></a>');
            }
            
    if(currentPage>10)
            {
                document.write(' 
    <a href="'+strURL+'?page='+(currentPage-10)+'" title="上十页"><font face=webdings>7</font></a> ');
            }
            document.write('
    <b>');
            
    for (i=p-p%10+1;i<p-p%10+1+10;i++)
            {
                
    if(i==pageNum+1
                    
    break;
                
    if(i==currentPage)
                {
                    document.write(' 
    <font color="'+fontcolor+'">'+i+'</font> ');
                }
                
    else
                {
                    document.write(' 
    <a href="'+strURL+'?page='+i+'">'+i+'</a> ');
                }
            }
            document.write('
    </b>');
            
    if(pageNum-currentPage>=10)
            {
                document.write('
    <a href="'+strURL+'?page='+(currentPage+10)+'" title="下十页"><font face=webdings>8</font></a> ');
            }
            
    if(currentPage!=pageNum)
            {
                document.write('
    <a href="'+strURL+'?page='+pageNum+'" title="尾页"><font face=webdings>:</font></a>  ');
            }
            
    else
            {
                document.write('
    <Font face=webdings color="'+fontcolor+'">:</font>');
            }
             
            document.write(' 转到:
    <input type=text size=3 maxlength=10 value="'+currentPage+'" name=Page><input type=submit value=Go name=submit>');//按钮好像不行,需要完善
            document.write('</div></td></tr>');
            document.write('
    </form></table>');
        
    </script>

            public string strURL="WebForm1.aspx";        
            
    public int recordNum=1000;
            
    public int perPageNum=20;
            
    public int pageIndex;
            
    public string tableWidth="100%";
            
    public string fontcolor="red";

            
    private void Page_Load(object sender, System.EventArgs e)
            
    {
                
    // 在此处放置用户代码以初始化页面
                pageIndex = System.Convert.ToInt32(Request.QueryString["page"]);
            }

  • 相关阅读:
    NET領域模型(1)
    oracle 函數索引(1)
    oracle 動態SQL(1)
    WF事件驱动(5)
    WF事件驱动(3)
    WF事件驱动(4)
    HP LoadRunner 11.00 新鲜尝
    Tomcat配置优化要点
    WebSphere性能诊断与调优
    性能测试工具、监控工具
  • 原文地址:https://www.cnblogs.com/xiaodi/p/123140.html
Copyright © 2020-2023  润新知