::烟舞者::

   

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

-=努力学习后台编程=-

 
ASP分页函数
作者:半支烟  发表时间:2006-2-13

 

<%
  Sub PageControl(iCount,pagecount,page,table_style,font_style)
'生成上一页下一页链接
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("<div " & Table_style & ">" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;"">" & vbCrLf )
Response.Write("" & vbCrLf )
Response.Write(font_style & vbCrLf )

if page<=1 then
Response.Write ("首页 " & vbCrLf)
Response.Write ("上页 " & vbCrLf)
else
Response.Write("<a href=" & action & "?" & temp & "Page=1>首页</a> " & vbCrLf)
Response.Write("<a href=" & action & "?" & temp & "Page=" & (Page-1) & ">上页</a> " & vbCrLf)
end if

if page>=pagecount then
Response.Write ("下页 " & vbCrLf)
Response.Write ("尾页 " & vbCrLf)
else
Response.Write("<a href=" & action & "?" & temp & "Page=" & (Page+1) & ">下页</a> " & vbCrLf)
Response.Write("<a href=" & action & "?" & temp & "Page=" & pagecount & ">尾页</a> " & vbCrLf)
end if

Response.Write(" 页次:" & page & "/" & pageCount & "页" & vbCrLf)
Response.Write(" 共有" & iCount & "个客户" & vbCrLf)
Response.Write(" 转到" & "<input type='text' name=page size=1 Maxlength=5 value=" & page & " class='InputText' />" & "页" & vbCrLf & "<input type='submit' value='GO' class='InputButton' />")
Response.Write("" & vbCrLf )
Response.Write("</form>" & vbCrLf )
Response.Write("</div>" & vbCrLf )
End Sub

   %>
'应用
<table>
<%if rs.recordcount>0 then%>
  rs.PageSize=20 '每页记录条数
  iCount=rs.RecordCount '记录总数
  iPageSize=rs.PageSize
  maxpage=rs.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

  rs.AbsolutePage=Page

    if page=maxpage then
      x=iCount-(maxpage-1)*iPageSize
    else
      x=iPageSize
    end if
  
for i=1 to x%>
<tr bgcolor="#FFFFFF">
<td width="44"><div align="center"><%=rs("ID")%></div></td>
<td width="309"><a href="Submit.asp?action=edit&id=<%=rs("ID")%>"><%=rs("AAA")%></a></td>
<td width="257"><%=rs("BBB")%></td>
<td width="73"><div align="center"><%=rs("CCC")%> M</div></td>
<td width="139"><div align="center"><%=rs("DDD")%></div></td>
</tr>
<%rs.movenext
Next%>
<tr bgcolor="#FFFFFF">
<td colspan="5"><div align="center">
  <%
  call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
  %>
  </div></td>
</tr>
<%rs.close
end if%>
</table>

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

 

半支烟发表于:ASP  


 

全部分类中有 1 篇日志 | 每页显示 1 篇
留言内容(共有条)


{CommentAuthor}评论说:
{CommentContent}

--- {CommentTime} {CommentUrl}


 

流年--似水


也说--几句


 来来--往往


 

 快速--登陆

*用户名:
*密   码:

 


日志--搜索


踩上--几脚

 
zzj 最新的 20 条日志
 

 

 

Designed By UBABY--2005