ASP pagination (2 paging program by oneself) _ Application Skills

Source: Internet
Author: User

<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>asp Paging Program </title>
<style type= "Text/css" >
<!--
. STYLE1 {font-size:12px}
-->
</style>
<body>
<p>
<table width= "186" height= "1" border= "0" cellpadding= "0" >
<tr>
<td> name </td>
<td> Password </td>
</tr>
<%
Set Rs=server.createobject ("Adodb.recordset")
conn = "dbq=" + Server.MapPath ("Zheng.mdb") + ";D efaultdir=;D river={microsoft Access DRIVER (*.mdb)};"
Sql= "SELECT * from User"

Rs.Open sql,conn,1,2
Rs.pagesize=6 ' Set page to show number of pages
If Request ("page") <> "then
Epage=cint (Request ("page")
If Epage<1 then epage=1
If Epage>rs.pagecount then Epage=rs.pagecount
Else
Epage=1
End If
Rs.absolutepage=epage
For I=0 to Rs.pagesize-1
If Rs.bof or rs.eof then exit for
%><tr>
<td><%=rs ("name")%></td>
<td><%=rs ("Pass")%></td>
</tr>


<%
Rs.movenext
Next
%>
</table>
<div align= "left" ><span class= "STYLE1" >
<form method= "Get" onsubmit= "document.location =" c.asp? Page= ' + This.page.value;return false; ' " >
<%if epage=1 Then Response. Write ("Home") else response. Write ("<a href= ' c.asp?page=1 ' >" & "Home" & "</a>")%>

<%if epage=1 Then Response.Write ("previous page") Else Response.Write "<a href=c.asp?page=" &epage-1& "> previous page </ A> "%>

<%if epage = Rs.pagecount Then Response.Write ("next page") Else Response.Write "<a href=c.asp?page=" &epage+1& " > next page </a> "%>

<%if epage = Rs.pagecount Then Response.Write ("last page") Else Response.Write "<a href=c.asp?page=" &rs.pagecount & "> Last </a>"%>
Now is the first <font color= "red" ><%=epage%></font> page altogether has <font color= "Red" ><%=rs.pagecount%>< /FONT> Page
<input name= "page" value= "<%=epage%>" maxlength=5 tyep=text/>
Page
<input type=submit value=go style= "font-size:12px;border:1px solid #CCCCCC width:23px;"/></form>
</div>
<p> </p>
<p>
<%

Name=request ("name")
Pass=request ("Pass")
If name<> "" and pass<> "" Then
Rs. Addnew
RS ("name") =name
RS ("pass") =pass
Rs.update
Rs.close
End If
%>
</p>
</p>
<form id= "Form1" Name= "Form1" method= "Post" action= "" >
<p>
<input name= "name" type= "text" id= "name"/>
</p>
<p>
<input name= "Pass" type= "text" id= "pass"/>
<input type= "Submit" name= "Submission" value= "submitted"/>
</p>
</form>
<p>
<table width= "63%" border= "0" cellpadding= "0" cellspacing= "1" bgcolor= "#0000FF" style= "Border-collapse:collapse" >
<%
Set Mrs=server.createobject ("Adodb.recordset")
conn = "dbq=" + Server.MapPath ("Zheng.mdb") + ";D efaultdir=;D river={microsoft Access DRIVER (*.mdb)};"
Sql= "SELECT * from User"

Mrs.open sql,conn,1,1
If Mrs.bof and Mrs.eof Then
Response.Write "<span> No Records </span>"
Response.End
Else
Mrs.pagesize = 6 ' number of records per page
Icount=mrs.recordcount ' Total records
Ipagesize=mrs.pagesize
Maxpage=mrs.pagecount
Page=request ("page")

If not IsNumeric (page) or page= "" Then
Page=1
Else
Page=cint (page)
End If
If Page<1 Then
Page=1
ElseIf Page>maxpage Then
Page=maxpage
End If
Mrs.absolutepage=page
If Page=maxpage Then
x=icount-(maxpage-1) *ipagesize
Else
X=ipagesize
End If
End If

For I=1 to Mrs.pagesize

%>
<tr>
&LT;TD width= "64%" bgcolor= "#FFFFFF" class= "STYLE1" ><%=mrs ("name")%></td>
&LT;TD width= "36%" bgcolor= "#FFFFFF" class= "STYLE1" ><%=mrs ("pass")%></td>
</tr><%
Mrs.movenext
If mrs.eof then Exit for
Next
Mrs.close
Set mrs=nothing
%>
<tr>
&LT;TD colspan= "2" bgcolor= "#CCCCCC" >
<span class= "STYLE1" >
<%
Call Pagecontrol (Icount,maxpage,page)
Sub Pagecontrol (Icount,pagecount,page)

' Generate previous page next page link
Dim query, a, X, temp
Action = "http://" & Request.ServerVariables ("Http_host") & Request.ServerVariables ("Script_name")
query = Split (Request.ServerVariables ("query_string"), "&")
For each x in query
A = Split (x, "=")
If StrComp (A (0), "page", vbTextCompare) <> 0 Then
Temp = temp & A (0) & "=" & A (1) & "&"
End If
Next
Response.Write ("<table border= ' 0 ' cellpadding= ' 3" style= ' border-collapse:collapse ' width= ' 100% ' "align= ' center ') > ")
Response.Write ("<form method=get onsubmit=" "document.location = '" & Action & "" & Temp & "page=" + thi S.page.value;return false; "" ><tr> ")
Response.Write ("<td align= ' center ' bgcolor= ' #FFFFFF ' >")
If Page<=1 Then
Response.Write ("Home")
Response.Write ("previous page")
Else
Response.Write ("<a href=" & Action & "?" & Temp & "Page=1> home </a>")
Response.Write ("<a href=" & Action & "?" & Temp & "Page=" & (Page-1) & "> Prev </a>")
End If
If Page>=pagecount Then
Response.Write ("next page")
Response.Write ("Last")
Else
Response.Write ("<a href=" & Action & "?" & Temp & "Page=" & (page+1) & "> Next page </a>")
Response.Write ("<a href=" & Action & "?" & Temp & "page=" & PageCount & "> Last </a>")
End If
Response.Write ("Page:" & page & "/" & PageCount & "page")
Response.Write ("Total" & icount & "message")
Response.Write ("goto" & "<input tyep=text name=page maxlength=5 value=" & Page & "style=" Font-size:12px;b order:1px solid #CCCCCC; width:23px; ' > & page <input type=submit style= "font-size:9pt" "Value=go style= ' font-size:12px;border:1px solid #CCCCCC; w idth:23px; ' > ")
Response.Write ("</td></tr></form>")
Response.Write ("</table>")

End Sub
%>
</span></td>
</tr>
</table>

<span class= "STYLE1" >
</p>

</form>
</body>

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.