An anti-google paging instance

Source: Internet
Author: User
Paramnametotal total number of records paramparamparamnameper number of records per page paramparamnamepage current page paramparamnamequery_stringUrl parameter param returns a paging style (string) privatestringPagination (inttotal, intpe

/// Param name = "total" number of records/param // param name = "per" number of records per page/param // param name = "page" Current page /param // param name = "query_string" Url parameter/param // return a paging style (string) with HTML code) private string Pagination (int total, int pe

///Total number of records
///Number of records per page
///Current page number
///Url parameters
/// Return a paging style (string) with HTML code)
Private string Pagination (int total, int per, int page, string query_string)
{
Int allpage = 0;
Int next = 0;
Int pre = 0;
Int startcount = 0;
Int endcount = 0;
String pagestr = "";

If (page <1) {page = 1 ;}
// Calculate the total number of pages
If (per! = 0)
{
Allpage = (total/per );
Allpage = (total % per )! = 0? Allpage + 1: allpage );
Allpage = (allpage = 0? 1: allpage );
}
Next = page + 1;
Pre = page-1;
Startcount = (page + 5)> allpage? Allpage-9: page-4; // The start Number of the intermediate page
// End number of the intermediate page
Endcount = page <5? 10: page + 5;
If (startcount <1) {startcount = 1;} // to avoid negative output, if it is smaller than 1, it starts from number 1.
If (allpage <endcount) {endcount = allpage;} // the possibility of page number + 5 will generate the final output sequence number greater than the total page number, then it should be controlled within the number of pages
Pagestr = "Total" + allpage + "page/page +" page ";


// Intermediate page processing, which increases the time complexity and reduces the space complexity
For (int I = startcount; I <= endcount; I ++)
{
Pagestr + = page = I? "" + I + "": "" + I + "";
}

Return pagestr;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.