ASP paging (self-organized two paging programs)

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">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> Asp PagingProgram</Title>
<Style type = "text/CSS">
<! --
. Style1 {font-size: 12px}
-->
</Style>

<Body>
<P>
<Table width = "186" Height = "39" border = "1" cellpadding = "0" cellspacing = "0">
<Tr>
<TD> name </TD>
<TD> password </TD>
</Tr>
<%
Set rs = server. Createobject ("ADODB. recordset ")
Conn = "DBQ =" + server. mappath ("Zheng. mdb") + "; defaultdir =; driver = {Microsoft Access Driver (*. mdb )};"
SQL = "select * from user"

Rs. Open SQL, Conn, 1, 2
Rs. pagesize = 6' set the number of pages displayed on the page.
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
%> <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 ("Homepage") else response. Write ("<a href = 'C. asp? Page = 1'> "&" Homepage "&" </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") 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 " last page " %>
the current page is on the <% = epage %> page. <% = Rs. pagecount %> page

page




<%

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
%>
















<% set Mrs = server. createobject ("ADODB. recordset ") conn =" DBQ = "+ server. mappath ("Zheng. mdb ") +"; defaultdir =; driver = {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 record </span>"
Response. End
Else
MRS. pagesize = 6' number of records per page
Icount = mrs. recordcount 'total number of 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>
<TD width = "64%" bgcolor = "# ffffff" class = "style1"> <% = Mrs ("name") %> </TD>
<TD width = "36%" bgcolor = "# ffffff" class = "style1"> <% = Mrs ("pass") %> </TD>
</Tr> <%
MRS. movenext
If Mrs. EOF then exit
Next
MRS. Close
Set MRS = nothing
%>
<Tr>
<TD colspan = "2" bgcolor = "# cccccc">
<SPAN class = "style1">
<%
Call pagecontrol (icount, maxpage, page)
Sub pagecontrol (icount, pagecount, page)

'Generate the next page of the previous page.
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 = '000000' align = 'center'> ")
Response. Write ("<form method = get onsubmit =" "document. Location = '" & Action &"? "& Temp &" page = '+ this. Page. value; return false; ""> <tr> ")
Response. Write ("<TD align = 'center' bgcolor = '# ffff'> ")
If page <= 1 then
Response. Write ("Homepage ")
Response. Write ("Previous Page ")
Else
Response. Write ("<a href =" & Action &"? "& Temp &" page = 1> homepage </a> ")
Response. Write ("<a href =" & Action &"? "& Temp &" page = "& (page-1) &"> previous page </a> ")
End if
If page> = pagecount then
Response. Write ("next page ")
Response. Write ("last page ")
Else
Response. Write ("<a href =" & Action &"? "& Temp &" page = "& (page + 1) &"> next page </a> ")
Response. Write ("<a href =" & Action &"? "& Temp &" page = "& pagecount &"> last page </a> ")
End if
Response. Write ("Page:" & page & "/" & pagecount & "page ")
Response. Write ("Total" & icount & "messages ")
Response. write ("go to" & "<input tyep = text name = page maxlength = 5 value =" & page & "style = 'font-size: 12px; Border: 1px solid # cccccc; width: 23px; '> "&" page <input type = submit style = "" font-size: 9pt "" value = go style = 'font-size: 12px; Border: 1px solid # cccccc; width: 23px; '> ")
Response. Write ("</TD> </tr> </form> ")
Response. Write ("</table> ")

End sub
%>
</Span> </TD>
</Tr>
</Table>

<SPAN class = "style1">
</P>

</Form>
</Body>
</Html>

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.