ASP million-page program code _ Application Skills

Source: Internet
Author: User

This is just an ASP tip class thing, although 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
Set rs=server.createobject ("ADODB") is omitted. RECORDSET ")
Rs. Open SQL, Conn, 1, 1
if not rs.eof then
pages = 30 ' Define the number of records per page
rs.pagesize = Pages ' defines the number of records displayed per page
ALLP ages = Rs.pagecount ' calculates how many pages page
= request.querystring ("page") ' through the browser ' page
' if statement is a basic error-handling
if IsEmpty (p Age) or Cint (page) [1 then
page = 1
elseif Cint (page) > allpages then
page = Allpages end
I F
Rs.   AbsolutePage = page
do, not rs.eof and pages > 0%>
Here's what
you want to do ... and so on. <% pages = Pages-1
Rs. MoveNext
Loop
Else
Response.Write ("Database 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 = "
    " txt = txt & "" 
       If i = Cint (page) then txt = txt & " txt = txt &"  ∥ 
     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 . it means that in the first code, in addition to the SQL query content and output can be changed, other declarations Recordset objects, page, pages, allpages these variables can not be changed, otherwise it will not run ~ In fact, this program is irrelevant, the most important thing is that this paging function can be called in any ASP leaf.

Pagination do not very beautiful, experts can modify the changes, learn from each other!

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.