Aforementioned:
1.
File to be paged: A. asp-------- Call the pagination function in page_turn.asp in this file: <% call select_page (xx. xx...) %>
2.Page_turn.asp-------- Here is a display function with parameters: private sub select_page (page_num, total). These two parameters are at least parameters to be passed, the current page number and the total page number of the record set.
A. asp contains page_turn.asp, <! -- # Include file = page_turn.asp -->
Body:
I encountered a problem when performing ASP paging. When the paging address contains parameters other than the page number (pagenum, manually add the required parameters (call selectpage (page_num, total, product category A, product category B) by calling the call custom paging function to pass variable parameters )), then, manually add each extra parameter to the connection of the selectpage function.
For example, <a href = "XXX. asp? Pagenum = 2 & product category name = variable A & product category name = variable B "> next page </a>
If all the same parameter names and numbers are good, but if the parameters are not fixed, it is changeable and you can only create a paging function.Select_page2 ()So we need to get the URL value through the following methods, as long as the extra parameter ID and value are assigned to a variable A, it can be used in all files (such: select_page (page_num, total, )).
How to know the URL of the current page, especially the URL usually contains parameters. If there is no parameter, only "request. servervariables ("script_name") ", but how can I get the URL with parameters? After online query and research, we use the following functions:
1. Function for obtaining the current URL parameter
2 Private function geturl ()
3dim scriptaddress, m_itemurl, m_item
4 scriptaddress = CSTR (request. servervariables ("script_name") 'Get the current address
5m_itemurl = ""
6if (request. querystring <> "") then
7 scriptaddress = scriptaddress &"? "
8 For each m_item in request. querystring
9 If m_item = "page_num" then exit for 'the function here is to filter out the page_num page parameters (this parameter is set in page_turn.asp, changes based on personal settings). Otherwise, this parameter will be added every time you flip the page. Although this parameter does not affect the function, it is always not good ~~
10 if instr (page, m_item) = 0 then
11 m_itemurl = m_itemurl & m_item & "=" & server. urlencode (request. querystring ("" & m_item &""))&"&"
12 end if
13 next
14 else
15 scriptaddress = scriptaddress &"? "
16end if
17 geturl = scriptaddress & m_itemurl
18end Function
Save the above Code as any ASP file, include the file in the file to implement the paging function, and assign the obtained address to a variable in the paging file, here is the URL. <% url = geturl () %>
Now, add the parameter URL <% call select_page (page_num, total, URL) %> to the function displayed on the page.
Get it done, retreat!