asp数字分页导航示例

  一个asp生成数字分页导航的示例代码,可以指定每次显示多少个数字导航,效果点击这里查看

dim CurrentPage'当前页
dim CurrentPageKey'页码键名称
dim TotalRecord'总记录数
dim TotalPage'总页数
dim PageSize'每页显示多少条
dim NumberPageSize'显示多少个页码
dim pms'查询的其他参数
 function getguider()
  dim nStr,istart, iend,sconnect:nStr = ""
  if pms<>"" then sconnect="&"
  if CurrentPage mod NumberPageSize = 0 then
    istart = CurrentPage
  else
    istart = int(CurrentPage / NumberPageSize) * NumberPageSize + 1
  end if
  if istart <> 1 and istart = CurrentPage then istart=istart - 1
  iend = istart + NumberPageSize
  if iend > TotalPage then
    iend = TotalPage + 1
    if iend - istart < NumberPageSize then istart = iend - NumberPageSize
    if istart < 1 then istart = 1
  end if
  iend=iend-1
  for  i = istart to iend
    if i = CurrentPage then
      nStr =nStr& " <font color='red'>[" & i & "]</font>"
    else
      nStr =nStr&" <a href='?" & pms & sconnect & CurrentPageKey & "=" & i & "'>" & i & "</a>"
    end if
  next
  getguider=nStr
 end function
 '=======================测试
 NumberPageSize=5'每次显示5个页码
 TotalPage=28'总页数设置为25,自己根据数据库计算得到这个值
 CurrentPageKey="p"'页码键名称
 CurrentPage=request.QueryString(CurrentPageKey)&""
 if not isnumeric(CurrentPage) then
   CurrentPage=1
 else
   CurrentPage=cint(CurrentPage)
 end if
 response.Write getguider()

 

加支付宝好友偷能量挖...


原创文章,转载请注明出处:asp数字分页导航示例

评论(0)Web开发网
阅读(188)喜欢(0)Asp/VBScript