ASP Paging Code (general)

Source: Internet
Author: User
Tags prev servervariables urlencode

<%
Recordset name _total = Recordset name. RecordCount

If (recordset name _numrows < 0) Then
Recordset name _numrows = Recordset name _total
Elseif (recordset name _numrows = 0) Then
Recordset Name _numrows = 1
End If

Recordset Name _first = 1
Recordset name _last = Recordset name _first + Recordset name _numrows-1

If (recordset name _total <>-1) Then
If (recordset name _first > Recordset First name _total) Then Recordset name _first = Recordset name _total
If (recordset name _last > Recordset First name _total) Then Recordset name _last = Recordset name _total
If (recordset name _numrows > Recordset First name _total) Then Recordset name _numrows = Recordset name _total
End If
%>
<%

If (recordset name _total =-1) Then

Recordset Name _total=0
While (the not recordset name.) EOF)
Recordset name _total = Recordset name _total + 1
Recordset name. MoveNext
Wend

If (recordset name.) CursorType > 0) Then
Recordset name. MoveFirst
Else
Recordset name. Requery
End If

If (recordset name _numrows < 0 Or Recordset name _numrows > Recordset name _total) Then
Recordset name _numrows = Recordset name _total
End If

Recordset Name _first = 1
Recordset name _last = Recordset name _first + Recordset name _numrows-1
If (recordset name _first > Recordset First name _total) Then Recordset name _first = Recordset name _total
If (recordset name _last > Recordset First name _total) Then Recordset name _last = Recordset name _total

End If
%>
<%
Set mm_rs = Recordset Name
Mm_rscount = Recordset name _total
Mm_size = Recordset name _numrows
Mm_uniquecol = ""
Mm_paramname = ""
Mm_offset = 0
Mm_attotal = False
Mm_paramisdefined = False
If (Mm_paramname <> "") Then
mm_paramisdefined = (Request.QueryString (mm_paramname) <> "")
End If
%>

<%
if (not mm_paramisdefined and mm_rscount <> 0) Then

r = Request.QueryString ("index")
If r = "" Then r = request.querystring ("offset")
If r <> "" Then Mm_offset = Int (r)

<%

Mm_removelist = "&index="
If (Mm_paramname <> "") Then mm_removelist = mm_removelist & "&" & mm_paramname & "="
Mm_keepurl= "": mm_keepform= "": mm_keepboth= ": mm_keepnone=" "

For each Item in Request.QueryString
Nextitem = "&" & Item & "="
If (INSTR (1,mm_removelist,nextitem,1) = 0) Then
Mm_keepurl = Mm_keepurl & Nextitem & Server.URLEncode (Request.QueryString (Item))
End If
Next

For each Item in Request.Form
Nextitem = "&" & Item & "="
If (INSTR (1,mm_removelist,nextitem,1) = 0) Then
Mm_keepform = mm_keepform & Nextitem & Server.URLEncode (Request.Form (Item))
End If
Next

Mm_keepboth = Mm_keepurl & Mm_keepform
if (Mm_keepboth <> "") Then Mm_keepboth = Right (Mm_keepboth, Len (Mm_keepboth)-1)
if (Mm_keepurl <> "") Then Mm_keepurl = Right (Mm_keepurl, Len (Mm_keepurl)-1)
if (Mm_keepform <> "") Then Mm_keepform = Right (Mm_keepform, Len (mm_keepform)-1)

Function Mm_joinchar (FirstItem)
If (FirstItem <> "") Then
Mm_joinchar = "&"
Else
Mm_joinchar = ""
End If
End Function
%>
<%
Mm_keepmove = Mm_keepboth
Mm_moveparam = "Index"

if (mm_size > 0) Then
Mm_moveparam = "offset"
If (Mm_keepmove <> "") Then
params = Split (mm_keepmo VE, "&"
Mm_keepmove = ""
For i = 0 to UBound (params)
Nextitem = left (params (i), InStr (params (i), "=")-1)
If (StrComp (nextitem,mm_moveparam,1) <> 0) Then
Mm_keepmove = mm_keepmove & "&" & Params (i)
End If
Next
if (mm_keepmove <> "") Then
Mm_keepmove = Right (Mm_keepmove, Len (mm_keepmove)-1)
End If
End If
End if

If (Mm_keepmove <> "") Then Mm_keepmove = mm_keepmove & "&"
Urlstr = Request.ServerVariables ("URL") & "?" & Mm_keepmove & mm_moveparam & "="
Mm_movefirst = urlstr & "0"
Mm_movelast = Urlstr & "-1"
Mm_movenext = urlstr & Cstr (Mm_offset + mm_size)
Prev = Mm_offset-mm_size
If (prev < 0) Then prev = 0
Mm_moveprev = urlstr & Cstr (prev)
%>
<script language= "JavaScript" >
function Jumpage (selobj,restore) {
Eval ("location= '" +selobj.options[selobj.selectedindex].value+ "");
if (restore) selobj.selectedindex=0;}
</script>

<select name= "pages" Size=1 onchange= "Jumpage (this,0)" class= "TXTFLD" >
<%
Tm_counter = 0
For i = 1 to recordset name _total step mm_size
Tm_counter = Tm_counter + 1
Tm_pageendcount = i + mm_size-1
If Tm_pageendcount > Recordset name _total Then tm_pageendcount = Recordset name _total
If I <> Mm_offset + 1 Then
%>
<option value= "<%=request.servervariables (" URL ") &"? "& Mm_keepmove &" offset= "& i-1%>" >
Section <%= tm_counter%> page </option>
<% Else%>
<option selected> <%=TM_counter%> Page </option>
<% End If%>
<% Next%>
</select>
<input type= "button" class= "Input" onclick= "location.href= ' <%=MM_movePrev%>" "value=" | "style=" font-family : ' Wingdings 3 ' "<% If mm_offset <> 0 Then
Response.Write ""
Else
Response.Write "Disabled"
End If%>>
<input type= "button" class= "Input" onclick= "location.href= ' <%=MM_moveNext%>" "value="} "style=" font-family : ' Wingdings 3 ' "<% If not mm_attotal Then
Response.Write ""
Else
Response.Write "Disabled"
End If%>>

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.