2 Common ASP Paging methods

Source: Internet
Author: User
Tags goto
Paging

I wrote 2 general ASP paging method for your reference!
<%@ Language=vbscript%>
<HTML>
<HEAD>
</HEAD>
<BODY>

<%
Dim CurrentPage ' Defines the current page
Dim filename ' filename
Const maxperpage=20 ' number of records displayed per page
Dim Totalnumber ' Total Records
Filename= "Showpages.asp"
totalnumber=200 ' Set record total of 200

If not IsEmpty (Request ("page") Then
Currentpage=cint (Request ("page")
Else
Currentpage=1
End If
Showpages Totalnumber,maxperpage,filename
%>
</BODY>
</HTML>
<% ' defines the paging function, with Totalnumber,maxperpage,filename as the entry for the function.
function Showpages (totalnumber,maxperpage,filename)
Dim n
If Totalnumber mod maxperpage=0 then
n= Totalnumber Maxperpage
Else
n= Totalnumber maxperpage+1
End If
Response.Write "<form method=post action=" &filename& ">"
Response.Write "<p align= ' center ' > Record Paging"
If Currentpage<2 Then
Response.Write "<font color= ' 999966 ' > Home prev </font>"
Else
Response.Write "<a href=" &filename& "?page=1> home </a>"
Response.Write "<a href=" &filename& "page=" &CurrentPage-1& "> previous page </a>"
End If
If N-currentpage<1 Then
Response.Write "<font color= ' 999966 ' > Next End </font>"
Else
Response.Write "<a href=" &filename& "page=" & (Currentpage+1)
Response.Write "> Next </a> <a href=" &filename& "? page=" &n& "> Last </a>"
End If
Response.Write "page: <strong><font color=red>" &CurrentPage& "</font>/" &n& "</ Strong> page "
Response.Write "goto: <input type= ' text ' name= ' page ' size=4 maxlength=10

Value= "&currentpage&" > "
Response.Write "<input class=buttonface type= ' Submit ' value= ' Goto ' name= ' Cndok ' ></span></p></ Form> "

End Function
%>

--------------------------------------------------------------------------

<%@ Language=vbscript%>
<HTML>
<HEAD>
</HEAD>
<BODY>

<%
Dim CurrentPage ' Defines the current page
Dim filename ' filename
Const maxperpage=20 ' number of records displayed per page
Dim Totalnumber ' Total Records
Filename= "Showpages.asp"
totalnumber=200 ' Set record total of 200

If not IsEmpty (Request ("page") Then
Currentpage=cint (Request ("page")
Else
Currentpage=1
End If
Showpages Totalnumber,maxperpage,filename
%>
</BODY>
</HTML>
<% ' defines the paging function, with Totalnumber,maxperpage,filename as the entry for the function.
function Showpages ()
Dim n
if (totalnumber mod maxperpage) =0 Then
n= Totalput Maxperpage
Else
n= Totalput Maxperpage + 1
End If
If N=1 Then
Exit Sub
End If
Dim k
Response.Write "<p align= ' left ' >>> pagination"
For K=1 to N
If K=currentpage Then
Response.Write "[<b>" +cstr (k) + "&LT;/B&GT;]"
Else
Response.Write "[<b>" + "<a href=" &filename& "page=" +cstr (k) + ">" +cstr (k) + "</a></b> ] "
End If
Next
Response.Write "</p>"
End Function
%>



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.