Another way to implement pagination

Source: Internet
Author: User
Tags implement
Pagination Hello, I'm Jackie Chan, I'm glad to see you again, and today we are talking about the "implementation of another page pagination"

At present, most of the pages introduced in the ASP book are all the number of pages are listed, we can imagine, if the page a lot of words the whole page will be replaced by the page number, very ugly, perhaps some people will say, I put the pagesize set a large number of it? Yes, it's a solution, but I don't recommend it, and I don't think any viewer will be able to drag the scroll bar patiently to find the information he needs.

The following is the author of the introduction of the most BBS in the use of the page display scheme, that has: home, previous page, the next page, last and jump to the dialog box hyperlink

Below, even if the implementation of the specific method
<title> Jackie ' s divding page</title>
<body>
<% ... open database ...
sqlstmt= "SELECT ..."
Mypage=request.querystring ("Whichpage")
If mypage= "" Then
Mypage=1
End If

Set Rs=server.creatobject ("Adodb.recordset")
Rs.Open sqlstmt,conn,adopenstatic
Rs.movefirst
' Remove the total number of pages
Maxcount=cint (Rs.pagecount)
Rs.absolutepage=mypage
%>
......... Display information for the page ... Slightly
<% scriptname=request.servervaribles ("Script.name")
Currentpage=cint (Rs.absolutepage)
Lastpage=cint (Rs.pagecount)
If currentpage<>1 or Currentpage<>lastpage then
%>
<a href= "<%=scriptname%>?whichpage=1" > Home </a>
<a href= "<%=scriptname%>?whichpage=<%=currentpage-1%> previous page </a>
<a href= "<%=scriptname%>?whichpage=<%=currentpage+1%> back Page </a>
<a href= "<%=scriptname%>?whichpage=<%=lastpage%> End </a>
<form action=<%=scriptname%>>
< input type= "text" name= "Whichpage" size=3>
<input type= "Submit" value= "Go" >
</form>

' After that, if the judgment is the first page or the last page of the statement
' If it's the first page
<%else if currentpage=1 then%>
First page Previous
<a href= "<%=scriptname%>?whichpage=<%=currentpage+1%> back Page </a>
<a href= "<%=scriptname%>?whichpage=<%=lastpage%> End </a>
<form action=<%=scriptname%>>
< input type= "text" name= "Whichpage" size=3>
<input type= "Submit" value= "Go" >
</form>

' If it's the last word
<a href= "<%=scriptname%>?whichpage=1" > Home </a>
<a href= "<%=scriptname%>?whichpage=<%=currentpage-1%> previous page </a>
Next Last
< input type= "text" name= "Whichpage" size=3>
<input type= "Submit" value= "Go" >
</form>
<%else
Response.Redirect scriptname& "? whichpage=1"
Endif%>


</body>

This paging program is generally the case, but there is a point is not to submit the form of the page on the input of the non-digital information processing, here is not to do the introduction, interested friends can add their own corresponding treatment.


Note: Due to the recent period of time the machine is not around, the above code does not debug, I was in the Internet café with the writing board, may be the above code will have some errors, but the author of this article to write the goal is to those who are learning ASP's friends to provide another way of thinking.



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.