以下几个过程是自己在工作中写出来的,虽然不好看,但满好用,在需要的地方调用,就可以产生不同样式的分页
调用方法:
产生效果:
'产生下拉列表式的页面导航栏
Sub BuildDropDownPageSelector(Total,TotalRecord)
dim strUrl
Dim Para
dim CurrentPageId
strUrl=Request.ServerVariables("URL")
if Request.QueryString.Count>0 then
strUrl=strUrl+"?"
for each Para in Request.QueryString
strUrl=strUrl+Para+"="+Request.QueryString(Para)+"&"
next
strUrl=Left(strUrl,Len(strUrl)-1)
end if
Set regEx = New RegExp
regEx.Pattern = "&PageId="+Request.QueryString("PageId")
regEx.IgnoreCase = True
regEx.Global = True
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")+"&"
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"?")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
End if
end if
end if
'仅在大于一页时显示导航栏
if Total>1 then
'产生一个合理的URL,有两种情况,一种是附有其他参数,一种是等于Request.SErverVariables("URL")的结果
Response.write "<table width='100%' border=0 cellpadding=2 cellspacing=0 id='Pager'><tr><td align=right>"
Response.write "共<u><b>"&TotalRecord&"</b></u>条记录 "
if strUrl=Request.ServerVariables("URL") then
response.write "跳转到 <select OnChange=""window.location.href='"&strURL&"?PageId='+this.options[this.selectedIndex].value"">"
else
response.write "跳转到 <select OnChange=""window.location.href='"&strURL&"&PageId='+this.options[this.selectedIndex].value"">"
end if
CurrentPageId=cint(Request.querystring("PageId"))
'处理PAGEID超过范围的情况
if CurrentPageId<1 then CurrentPageId=1
if CurrentPageId>Total then CurrentPageId=Total
for i=1 to Total
if CurrentPageId=cint(i) then
response.write "<option value='"&i&"' selected>第"&i&"页</option>"
else
response.write "<option value='"&i&"'>第"&i&"页</option>"
end if
next
Response.write "</select>"
response.write "</td></tr></table>"
end if
End Sub
Sub BuildDropDownPageSelector(Total,TotalRecord)
dim strUrl
Dim Para
dim CurrentPageId
strUrl=Request.ServerVariables("URL")
if Request.QueryString.Count>0 then
strUrl=strUrl+"?"
for each Para in Request.QueryString
strUrl=strUrl+Para+"="+Request.QueryString(Para)+"&"
next
strUrl=Left(strUrl,Len(strUrl)-1)
end if
Set regEx = New RegExp
regEx.Pattern = "&PageId="+Request.QueryString("PageId")
regEx.IgnoreCase = True
regEx.Global = True
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")+"&"
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"?")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
End if
end if
end if
'仅在大于一页时显示导航栏
if Total>1 then
'产生一个合理的URL,有两种情况,一种是附有其他参数,一种是等于Request.SErverVariables("URL")的结果
Response.write "<table width='100%' border=0 cellpadding=2 cellspacing=0 id='Pager'><tr><td align=right>"
Response.write "共<u><b>"&TotalRecord&"</b></u>条记录 "
if strUrl=Request.ServerVariables("URL") then
response.write "跳转到 <select OnChange=""window.location.href='"&strURL&"?PageId='+this.options[this.selectedIndex].value"">"
else
response.write "跳转到 <select OnChange=""window.location.href='"&strURL&"&PageId='+this.options[this.selectedIndex].value"">"
end if
CurrentPageId=cint(Request.querystring("PageId"))
'处理PAGEID超过范围的情况
if CurrentPageId<1 then CurrentPageId=1
if CurrentPageId>Total then CurrentPageId=Total
for i=1 to Total
if CurrentPageId=cint(i) then
response.write "<option value='"&i&"' selected>第"&i&"页</option>"
else
response.write "<option value='"&i&"'>第"&i&"页</option>"
end if
next
Response.write "</select>"
response.write "</td></tr></table>"
end if
End Sub
'产生前一页后一页式页面导航栏
Sub BuildFirstLastPageNavigate(Total,TotalRecord)
dim strUrl
Dim Para
dim CurrentPageId
strUrl=Request.ServerVariables("URL")
if Request.QueryString.Count>0 then
strUrl=strUrl+"?"
for each Para in Request.QueryString
strUrl=strUrl+Para+"="+Request.QueryString(Para)+"&"
next
strUrl=Left(strUrl,Len(strUrl)-1)
end if
Set regEx = New RegExp
regEx.Pattern = "&PageId="+Request.QueryString("PageId")
regEx.IgnoreCase = True
regEx.Global = True
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")+"&"
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"?")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
End if
end if
end if
'仅在大于一页时显示导航栏
if Total>1 then
'产生一个合理的URL,有两种情况,一种是附有其他参数,一种是等于Request.SErverVariables("URL")的结果
Response.write "<table width='100%' border=0 cellpadding=2 cellspacing=0 id='Pager'><tr><td align=right>"
CurrentPageId=cint(Request.querystring("PageId"))
'处理PAGEID超过范围的情况
if CurrentPageId<1 then CurrentPageId=1
if CurrentPageId>Total then CurrentPageId=Total
Response.write "共<u><b>"&TotalRecord&"</b></u>条记录 当前是第 <u><b>"&CurrentPageId&"</b></u> 页 "
if CurrentPageId>1 then
if strUrl=Request.ServerVariables("URL") then
response.write "<img src='/images/first.gif' border=0 align=absmiddl><a href='"+strUrl+"?PageId=1'>首页</a> <img src='/images/prev.gif' border=0 align=absmiddl> <a href='"+strUrl+"?PageId="&(CurrentPageId-1)&"'>上一页</a> "
else
response.write "<img src='/images/first.gif' border=0 align=absmiddl><a href='"+strUrl+"&PageId=1'>首页</a> <img src='/images/prev.gif' border=0 align=absmiddl> <a href='"+strUrl+"&PageId="&(CurrentPageId-1)&"'>上一页</a> "
end if
end if
if CurrentPageId<Total then
if strUrl=Request.ServerVariables("URL") then
response.write "<img src='/images/next.gif' border=0 align=absmiddl><a href='"+strUrl+"?PageId="&(CurrentPageId+1)&"'>下一页</a> <img src='/images/Last.gif' border=0 align=absmiddl> <a href='"+strUrl+"?PageId="&Total&"'>尾页</a> "
else
response.write " <img src='/images/next.gif' border=0 align=absmiddl><a href='"+strUrl+"&PageId="&(CurrentPageId+1)&"'>下一页</a> <img src='/images/Last.gif' border=0 align=absmiddl> <a href='"+strUrl+"&PageId="&Total&"'>尾页</a>"
end if
end if
response.write "</td></tr></table>"
end if
End Sub
Sub BuildFirstLastPageNavigate(Total,TotalRecord)
dim strUrl
Dim Para
dim CurrentPageId
strUrl=Request.ServerVariables("URL")
if Request.QueryString.Count>0 then
strUrl=strUrl+"?"
for each Para in Request.QueryString
strUrl=strUrl+Para+"="+Request.QueryString(Para)+"&"
next
strUrl=Left(strUrl,Len(strUrl)-1)
end if
Set regEx = New RegExp
regEx.Pattern = "&PageId="+Request.QueryString("PageId")
regEx.IgnoreCase = True
regEx.Global = True
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")+"&"
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"?")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
End if
end if
end if
'仅在大于一页时显示导航栏
if Total>1 then
'产生一个合理的URL,有两种情况,一种是附有其他参数,一种是等于Request.SErverVariables("URL")的结果
Response.write "<table width='100%' border=0 cellpadding=2 cellspacing=0 id='Pager'><tr><td align=right>"
CurrentPageId=cint(Request.querystring("PageId"))
'处理PAGEID超过范围的情况
if CurrentPageId<1 then CurrentPageId=1
if CurrentPageId>Total then CurrentPageId=Total
Response.write "共<u><b>"&TotalRecord&"</b></u>条记录 当前是第 <u><b>"&CurrentPageId&"</b></u> 页 "
if CurrentPageId>1 then
if strUrl=Request.ServerVariables("URL") then
response.write "<img src='/images/first.gif' border=0 align=absmiddl><a href='"+strUrl+"?PageId=1'>首页</a> <img src='/images/prev.gif' border=0 align=absmiddl> <a href='"+strUrl+"?PageId="&(CurrentPageId-1)&"'>上一页</a> "
else
response.write "<img src='/images/first.gif' border=0 align=absmiddl><a href='"+strUrl+"&PageId=1'>首页</a> <img src='/images/prev.gif' border=0 align=absmiddl> <a href='"+strUrl+"&PageId="&(CurrentPageId-1)&"'>上一页</a> "
end if
end if
if CurrentPageId<Total then
if strUrl=Request.ServerVariables("URL") then
response.write "<img src='/images/next.gif' border=0 align=absmiddl><a href='"+strUrl+"?PageId="&(CurrentPageId+1)&"'>下一页</a> <img src='/images/Last.gif' border=0 align=absmiddl> <a href='"+strUrl+"?PageId="&Total&"'>尾页</a> "
else
response.write " <img src='/images/next.gif' border=0 align=absmiddl><a href='"+strUrl+"&PageId="&(CurrentPageId+1)&"'>下一页</a> <img src='/images/Last.gif' border=0 align=absmiddl> <a href='"+strUrl+"&PageId="&Total&"'>尾页</a>"
end if
end if
response.write "</td></tr></table>"
end if
End Sub
'产生数字式翻页按钮
Sub BuildNumericalPageNavigate(Total,TotalRecord)
dim strUrl
Dim Para
dim CurrentPageId
strUrl=Request.ServerVariables("URL")
if Request.QueryString.Count>0 then
strUrl=strUrl+"?"
for each Para in Request.QueryString
strUrl=strUrl+Para+"="+Request.QueryString(Para)+"&"
next
strUrl=Left(strUrl,Len(strUrl)-1)
end if
Set regEx = New RegExp
regEx.Pattern = "&PageId="+Request.QueryString("PageId")
regEx.IgnoreCase = True
regEx.Global = True
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")+"&"
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"?")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
End if
end if
end if
'仅在大于一页时显示导航栏
if Total>1 then
'产生一个合理的URL,有两种情况,一种是附有其他参数,一种是等于Request.SErverVariables("URL")的结果
Response.write "<table width='100%' border=0 cellpadding=2 cellspacing=0 id='Pager'><tr><td align=right>"
CurrentPageId=cint(Request.querystring("PageId"))
'处理PAGEID超过范围的情况
if CurrentPageId<1 then CurrentPageId=1
if CurrentPageId>Total then CurrentPageId=Total
if currentpageid mod 10=0 then
nextpageid=fix(currentpageid/10)*10+1
prevpageid=fix(currentpageid/10-1)*10
minpageid=fix(currentpageid/10-1)*10+1
maxpageid=fix(currentpageid/10)*10
currentppid=fix(currentpageid/10)
else
nextpageid=(fix(currentpageid/10)+1)*10+1
prevpageid=fix(currentpageid/10)*10
minpageid=fix(currentpageid/10)*10+1
maxpageid=(fix(currentpageid/10)+1)*10
currentppid=fix(currentpageid/10)+1
end if
if total mod 10=0 then
maxppid=fix(total/10)
else
maxppid=fix(total/10)+1
end if
if nextpageid>=total then
nextpageid=total
end if
if prevpageid<=1 then
prevpageid=1
end if
if minpageid<=1 then
minpageid=1
end if
if maxpageid>=total then
maxpageid=total
end if
if currentppid>1 then
response.write "<a href='"&strUrl&"?pageid="&prevpageid&"'></a> "
end if
for countery=minpageid to maxpageid
if countery=CurrentPageId then
response.write "<a href='"+strUrl+"?PageId="&countery&"' style='background-color:#666666;color:#ffffff'>"&countery&"</a>"
else
response.write "<a href='"+strUrl+"?PageId="&countery&"'>"&countery&"</a>"
end if
next
if currentppid<maxppid then
response.write " <a href='"&strUrl&"?pageid="&nextpageid&"'></a>"
end if
response.write "</td></tr></table>"
end if
End Sub
Sub BuildNumericalPageNavigate(Total,TotalRecord)
dim strUrl
Dim Para
dim CurrentPageId
strUrl=Request.ServerVariables("URL")
if Request.QueryString.Count>0 then
strUrl=strUrl+"?"
for each Para in Request.QueryString
strUrl=strUrl+Para+"="+Request.QueryString(Para)+"&"
next
strUrl=Left(strUrl,Len(strUrl)-1)
end if
Set regEx = New RegExp
regEx.Pattern = "&PageId="+Request.QueryString("PageId")
regEx.IgnoreCase = True
regEx.Global = True
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")+"&"
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"?")
else
regEx.Pattern="\?PageId="+Request.QueryString("PageId")
if regEx.Test(strUrl) then
strUrl=regEx.Replace(strUrl,"")
End if
end if
end if
'仅在大于一页时显示导航栏
if Total>1 then
'产生一个合理的URL,有两种情况,一种是附有其他参数,一种是等于Request.SErverVariables("URL")的结果
Response.write "<table width='100%' border=0 cellpadding=2 cellspacing=0 id='Pager'><tr><td align=right>"
CurrentPageId=cint(Request.querystring("PageId"))
'处理PAGEID超过范围的情况
if CurrentPageId<1 then CurrentPageId=1
if CurrentPageId>Total then CurrentPageId=Total
if currentpageid mod 10=0 then
nextpageid=fix(currentpageid/10)*10+1
prevpageid=fix(currentpageid/10-1)*10
minpageid=fix(currentpageid/10-1)*10+1
maxpageid=fix(currentpageid/10)*10
currentppid=fix(currentpageid/10)
else
nextpageid=(fix(currentpageid/10)+1)*10+1
prevpageid=fix(currentpageid/10)*10
minpageid=fix(currentpageid/10)*10+1
maxpageid=(fix(currentpageid/10)+1)*10
currentppid=fix(currentpageid/10)+1
end if
if total mod 10=0 then
maxppid=fix(total/10)
else
maxppid=fix(total/10)+1
end if
if nextpageid>=total then
nextpageid=total
end if
if prevpageid<=1 then
prevpageid=1
end if
if minpageid<=1 then
minpageid=1
end if
if maxpageid>=total then
maxpageid=total
end if
if currentppid>1 then
response.write "<a href='"&strUrl&"?pageid="&prevpageid&"'></a> "
end if
for countery=minpageid to maxpageid
if countery=CurrentPageId then
response.write "<a href='"+strUrl+"?PageId="&countery&"' style='background-color:#666666;color:#ffffff'>"&countery&"</a>"
else
response.write "<a href='"+strUrl+"?PageId="&countery&"'>"&countery&"</a>"
end if
next
if currentppid<maxppid then
response.write " <a href='"&strUrl&"?pageid="&nextpageid&"'></a>"
end if
response.write "</td></tr></table>"
end if
End Sub
调用方法:
sub BuildProductList(StyleMode,ProductPerPage,ProductPerRow)
i=1
response.write "<table align='center' cellpadding='0' cellspacing='0' width='100%' height='100%'>"
if totalrecord>productperpage then
response.write "<tr height=25><td colspan='"&(ProductPerRow*2)&"'>"
BuildNumericalPageNavigate totalpage,totalrecord
response.write "</td></tr>"
end if
response.write "<tr><td colspan='"&(ProductPerRow*2)&"' height=10></td></tr>"
i=1
response.write "<table align='center' cellpadding='0' cellspacing='0' width='100%' height='100%'>"
if totalrecord>productperpage then
response.write "<tr height=25><td colspan='"&(ProductPerRow*2)&"'>"
BuildNumericalPageNavigate totalpage,totalrecord
response.write "</td></tr>"
end if
response.write "<tr><td colspan='"&(ProductPerRow*2)&"' height=10></td></tr>"
产生效果: