zoukankan      html  css  js  c++  java
  • 在asp.net中长内容自动分页的实现.NET教程2

    using System; 
    using System.Data; 

     using System.Configuration; 

     using System.Collections; 

     using System.Web; 

     using System.Web.Security; 

     using System.Web.UI; 

     using System.Web.UI.WebControls; 

    using System.Web.UI.WebControls.WebParts; 

     using System.Web.UI.HtmlControls; 
     
    public partial class Page : System.Web.UI.Page 

    private string str;//字符15 private int strl;//字符总长度16 private int pagesize;//每页显示的字符数17 protected void Page_Load(object sender, EventArgs e) 

    // 在此处放置用户代码以初始化页面 20 str = "1234567891234567898522555"; 
    pagesize = 3; 
    strl = str.Length; 
    Response.Write(strl); 
    substr(); 

     
    private void substr() 

    int ct = Int32.Parse(Request.QueryString["page"]); 
    if (strl == (strl / pagesize) * pagesize)//看看页面的总记录是否能被每页的记录数整除31 { 
    for (int i = 1; i <= strl / pagesize; i++) 

    Response.Write("页:<a href="page.aspx?page=" mce_href="page.aspx?page="" + i + ">" + (i) + "</" + "a>"); 

    string s = str.Substring(pagesize * ct - pagesize, pagesize); 
    Response.Write(s); 

    else if (ct * pagesize > strl)//在不被整除的情况下,最后一页的设置,如字符长13,每页3,则处理最后那一页的显示40

     { 

     for (int i = 1; i <= (strl / pagesize) + 1; i++) 

    Response.Write("页:<a href="page.aspx?page=" mce_href="page.aspx?page="" + i + ">" + (i) + "</" + "a>"); 

    string s = str.Substring((ct - 1) * pagesize, strl - (ct - 1) * pagesize); 
    Response.Write(s); 

     else //在不被整除的情况下其他页面的显示设置49 { 
    for (int i = 1; i <= strl / pagesize + 1; i++) 

    Response.Write("页:<a href="page.aspx?page=" mce_href="page.aspx?page="" + i + ">" + (i) + "</" + "a>"); 

    string s = str.Substring(pagesize * ct - pagesize, pagesize); \


     Response.Write(s); 
    }

    }

    http://blog.csdn.net/duanxifeng888/archive/2010/08/22/5830468.aspx

  • 相关阅读:
    python 前置程序窗口,还原最小化的窗口
    GreenDao官方文档翻译(上)
    Android 使用Instrumentation进行界面的单元测试
    Android:View中的performClick()触发条件
    Java 单元测试(Junit)
    再看薄荷
    单例模式-Singleton
    Java 如何防止线程意外中止
    Java Error和Exception区别
    linux的进程1:rootfs与linuxrc
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/1910762.html
Copyright © 2011-2022 走看看