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.