ASP million paging program

Source: Internet
Author: User
Tags end error handling sql servervariables
Programs | paging | Pagination This is just an ASP tip class, it is suitable for each of the different file names call this function, but there are prerequisites, let's take a closer look at the story.
The following section is the basic page-splitting code:

<% sql = "Select ... ..... ........... The SQL statement is omitted
Set rs=server.createobject ("ADODB. RECORDSET ")
Rs. Open SQL, Conn, 1, 1
If not rs.eof then
Pages = 30 ' defines the number of records to display per page
rs.pagesize = Pages ' defines the number of records displayed per page
Allpages = Rs.pagecount ' Calculate how many pages can be divided altogether
page = request.querystring ("page") ' number of pages passed through the browser
' If statement belongs to the basic error handling
If IsEmpty (page) or Cint (page) 1 Then
page = 1
ElseIf Cint (page) > Allpages Then
page = Allpages
End If
Rs. AbsolutePage = page
Do, not rs.eof and pages 0%>
Here's what you want to do ..... ......
<% pages = pages-1
Rs. MoveNext
Loop
Else
Response.Write ("The database is not content!") ")
End If
Rs. Close
Set rs = Nothing%>
The system has been paging the data, and here's a look at the key issues of this discussion the definition of paging function

<% SUB Pageurl (PURL)
Dim Eurl
txts = Request.ServerVariables ("URL")
Txts = Left (Txts,instrrev (txts, "/", Len (txts))-1)
Eurl = "http://"; & Request.ServerVariables ("SERVER_NAME") & Txts
For I =1 to Allpages
txt = ""
txt = "<strong>"
txt = txt & "<a Href=" & Eurl & PUrl & "page=" &i & ">"
If i = Cint (Page) Then txt = txt & "<font color= ' bb0000 '"
txt = txt & (i)
If i = Cint (Page) Then txt = txt & "</font>"
txt = txt & "</a> ∥ </strong>"
Response.Write (TXT)
Next
End Sub%>
Save the page function code copy as an ASP file, and use include in the page you want to use to bring in the call ("/the filename you called?"). OK, like the one on my news page is called <%call ("/news.asp?") %>
There's a limit to what we've been up to. That is, in the first code, in addition to the SQL query content and output can be changed, the other declared Recordset object, page, pages, allpages these variables can not be changed, otherwise it will not run ~ In fact, this program is irrelevant, the most important is , the paging function can be invoked in any ASP leaf. Pagination do not beautiful, experts can modify the changes, can be sent to me, I will be responsible for you to publish it!



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.