Function-type display paging connection

Source: Internet
Author: User
Flip | function | show | page | Function This program will show the paging connection function to separate out, without involving other operations, can be built-in page effect, convenient and flexible.

Pagehanshu.asp
<%
' Set page numbers and URLs
' Value1 Paging address
' value2 Page's value
' Value3 address label eg: first page, next page
' Value4 according to Vaule1
' If value1 = ' page.asp ', value4 = 1; value1 = "Page.asp?id=1" when value4 = 0;

function Page_url (VALUE1,VALUE2,VALUE3,VALUE4)
Dim result
Dim val
If value4 = 1 Then
val = "?"
Else
val = "&"
End If
result = "<a href=" & value1 & val & "Page=" & value2 & ">" & value3 & "</a>"
Page_url = result
End Function



' The page parameter that gets the page is current
function Page_request ()
Dim page

page = Request ("page")
if (page <> "" and IsNumeric (page) = false) or page = "" Then
page = 1
End If
page_request = page
End Function



' Set the most commonly used paging mode, add and modify any
' The first effect is a little tedious to write
' N is the total number of pages
function Pagemode1 (value1,value2)
Dim out

Val1 = value1
Val4 = value2
page = Page_request ()
page = CInt (page)

Val2_1 = 1
Val2_2 = page-1
Val2_3 = page + 1
Val2_4 = n

Val3_1 = "First page"
Val3_2 = "Previous Page"
Val3_3 = "Next Page"
Val3_4 = "Last Page"

If page = 1 Then
OUT1 = Val3_1
Out2 = Val3_2
Else
OUT1 = Page_url (VAL1,VAL2_1,VAL3_1,VAL4)
Out2 = Page_url (VAL1,VAL2_2,VAL3_2,VAL4)
End If

If page = n Then
OUT3 = Val3_3
Out4 = Val3_4
Else
OUT3 = Page_url (VAL1,VAL2_3,VAL3_3,VAL4)
Out4 = Page_url (VAL1,VAL2_4,VAL3_4,VAL4)
End If

out = OUT1 & "" & Out2 & "& Out3 &" "& Out4

Pagemode1 = out
End Function


' The second kind of effect
' N is the total number of pages
function Pagemode2 (value1,value2)
Dim out
Val1 = value1
Val4 = value2

For i = 1 to n
Val2 = i
Val3 = "First" & I & "page"
out = out & Page_url (VAL1,VAL2,VAL3,VAL4) & ""
Next

Pagemode2 = out
End Function
%>



Use examples (borrow a Sunline friend's program)

<%

Sql= ".................
Rs.Open sql,conn,1,1 ' Join table
Rs.pagesize=10 ' This is a few records per page showing 10 represents 10 pieces
n = Rs.pagecount ' Get total pages

Page=page_request () ' Get page number value
Rs. Absolutepage=page
%>


Next, put the following code where you want to display the page-flipping link:
<%
out = Pagemode1 ("page.asp", 1)
' OR
out = Pagemode1 ("page.asp?id=1", 0)
' OR
out = Pagemode2 ("page.asp", 1)

Response.Write out
%>



Oh, this program does not have any new things, also did not pass any calculation speed test and performance optimization, purely for the convenience of use, please give more advice, let me improve.



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.