鉴于大家对ASP十分关注,我们编辑小组在此为大家搜集整理了“asp分页(自己整理的2个分页程序)”一文,供大家参考学习!
<%@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分页程序</title>
<style type="text/css">
<!--
.STYLE1 {font-size: 12px}
-->
</style></head>
<body>
<p>
<table width="186" height="39" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>姓名</td>
<td>密码</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 ''设置页面显示得页数
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("首页")else response.Write("<a href=''c.asp?page=1''>"&"首页"&"</a>")%>
<%if epage=1 then response.write("")else response.write"<a href=c.asp?page="&epage-1&"></a>"%>
<%if epage = rs.pagecount then response.write("")else response.write"<a href=c.asp?page="&epage+1&"></a>"%>
<%if epage = rs.pagecount then response.write("末页")else response.write"<a href=c.asp?page="&rs.pagecount&">末页</a>"%>
现在是第<font color="red"><%=epage%></font>页一共有<font color="red"><%=rs.pagecount%></font>页
<input name="page" value="<%=epage%>" maxlength=5 tyep=text />
页
<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="Submit" value="提交" />
</p>
</form>
<p>
<table width="63%" border="0" cellpadding="0" cellspacing="1" bgcolor="#0000FF" style="border-collapse: collapse">
<%
set mrs=server.cr