Asp. NET paging instance of pager

Source: Internet
Author: User
The ASP. NET paging can set the first page, previous page, next page, and the last displayed link text in the foreground. This is simply a reference to simple functions, and it is much easier to dig deeper into its principles.

Containerid the target container for navigation, it is recommended to use the span label//url The default is xxx.xx?pagenum=//curpage the current page number//maxsection the maximum number of segments (maximum pages in a section)//totalpa     GE total number of pages function Navigate (containerid,url,curpage,maxsection, totalpage) {//to the first page of the sign var. = "|<<";     To the last page of the sign var = ">>|";     Previous Page sign var back = "<"//Next page sign var next = ">";     Illegal page number processing if (Curpage > Totalpage | | curpage < 0) {curpage = 1;     }//Get navigation container parent element var containerobj = document.getElementById (Containerid);     Get the segment number where the current page is located (debug long time originally a type problem, incredibly float type) var cursection = Math.floor ((curPage-1)/maxsection + 1);     Get the last segment number var lastsection = Math.floor ((totalPage-1)/maxsection + 1);     var html = ""; The current page is not page 1th, added to the first page, and the previous if (Curpage > 1) {html + = "...     ";     }//The first page number of the current segment var Cursectionfirst = (curSection-1) * maxsection + 1;     Last page number of the current paragraph var cursecitonlast = cursection * maxsection; Outputs the page number for the current segment for (var i = cursectionfIrst I <= cursecitonlast && i <= totalpage; i++) {if (curpage = = i) {html + = "...     "; }//The current page is not the last page, add the next and last page symbols if (curpage! = totalpage) {html + = "<a data-cke-saved-href=" http://blog.csdn. net/jiangpeng59/article/details/"href=" http://blog.csdn.net/jiangpeng59/article/details/"" "+ +" "Url=" "(curpage=       "1) =" "" "=" ">" + Next + ""; html + = "}

Get the following pager implementation: |<< < ... 9-Ten ... > >>|

The above is the whole content of this article, I hope that everyone's learning has helped, but also hope that we support topic.alibabacloud.com.

Related Article

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.