asp可设置参数的分页代码例子
发布时间:2007-10-07 12:34:00
<%
''调用例子
'Dim int_RPP,int_Start,int_showNumberLink_,str_nonLinkColor_,toF_,toP10_,toP1_,toN1_,toN10_,toL_,showMorePageGo_Type_,cPageNo
'int_RPP=2 '设置每页显示数目
'int_showNumberLink_=8 '数字导航显示数目
'showMorePageGo_Type_ = 1 '是下拉菜单还是输入值跳转,当多次调用时只能选1
'str_nonLinkColor_="#999999" '非热链接颜色
'toF_="<font face=webdings>9</font>" '首页
'toP10_=" <font face=webdings>7</font>" '上十
'toP1_=" <font face=webdings>3</font>" '上一
'toN1_=" <font face=webdings>4</font>" '下一
'toN10_=" <font face=webdings>8</font>" '下十
'toL_="<font face=webdings>:</font>" '尾页
'这段代码一定要在VClass_Rs.Open 与 for循环之间
' Set VClass_Rs = CreateObject(G_FS_RS)
' VClass_Rs.Open This_Fun_Sql,User_Conn,1,1
' IF not VClass_Rs.eof THEN
' VClass_Rs.PageSize=int_RPP
' cPageNo=NoSqlHack(Request.QueryString("Page"))
' If cPageNo="" Then cPageNo = 1
' If not isnumeric(cPageNo) Then cPageNo = 1
' cPageNo = Clng(cPageNo)
' If cPageNo<=0 Then cPageNo=1
' If cPageNo>VClass_Rs.PageCount Then cPageNo=VClass_Rs.PageCount
' VClass_Rs.AbsolutePage=cPageNo
' FOr int_Start=1 TO int_RPP
''++++++++++
'加循环体显示数据
''++++++++++
' VClass_Rs.MoveNext
' if VClass_Rs.eof or VClass_Rs.bof then exit for
' NEXT
' END IF
'response.Write "<p>"& fPageCount(VClass_Rs,int_showNumberLink_,str_nonLinkColor_,toF_,toP10_,toP1_,toN1_,toN10_,toL_,showMorePageGo_Type_,cPageNo)
' 目的:分页的页面参数保持
' 提交查询的一致性
' 输入:moveParam:分页参数
' removeList:要移除的参数
' 返回:分页Url
Function PageUrl(moveParam,removeList)
dim strName
dim KeepUrl,KeepForm,KeepMove
removeList=removeList&","&moveParam
KeepForm=""
For Each strName in Request.Form
'判断form参数中的submit、空值
if not InstrRev(","&removeList&",",","&strName&",", -1, 1)>0 and Request.Form(strName)<>"" then
KeepForm=KeepForm&"&"&strName&"="&Server.URLencode(Request.Form(strName))
end if
removeList=removeList&","&strName
Next
KeepUrl=""
For Each strName In Request.QueryString
If not (InstrRev(","&removeList&",",","&strName&",", -1, 1)>0) Then
KeepUrl = KeepUrl & "&" & strName & "=" & Server.URLencode(Request.QueryString(strName))
End If
Next
KeepMove=KeepForm&KeepUrl
If (KeepMove <> "") Then
KeepMove = Right(KeepMove, Len(KeepMove) - 1)
KeepMove = Server.HTMLEncode(KeepMove) & "&"
End If
'PageUrl = replace(Request.ServerVariables("URL"),"/Search.asp","/Search.html") & "?" & KeepMove & moveParam & "="
PageUrl = "?" & KeepMove & moveParam & "="
End Function
Function fPageCount(Page_Rs,showNumberLink_,nonLinkColor_,toF_,toP10_,toP1_,toN1_,toN10_,toL_,showMorePageGo_Type_,Page)
Dim This_Func_Get_Html_,toPage_,p_,sp2_,I,tpagecount
Dim NaviLength,StartPage,EndPage
This_Func_Get_Html_ = "" : I = 1
NaviLength=showNumberLink_
if IsEmpty(showMorePageGo_Type_) then showMorePageGo_Type_ = 1
tpagecount=Page_Rs.pagecount
If tPageCount<1 Then tPageCount=1
if not Page_Rs.eof or not Page_Rs.bof then
toPage_ = PageUrl("Page","submit,GetType,no-cache,_")
if Page=1 then
This_Func_Get_Html_=This_Func_Get_Html_& "<font color="&nonLinkColor_&" title=""首页"">"&toF_&"</font> " &vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_& "<a href="&toPage_&"1 title=""首页"">"&toF_&"</a> " &vbNewLine
End If
if Page<NaviLength then
StartPage = 1
else
StartPage = fix(Page / NaviLength) * NaviLength
end if
EndPage=StartPage+NaviLength-1
If EndPage>tPageCount Then EndPage=tPageCount
If StartPage>1 Then
This_Func_Get_Html_=This_Func_Get_Html_& "<a href="&toPage_& Page - NaviLength &" title=""上"&int_showNumberLink_&"页"">"&toP10_&"</a> " &vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_& "<font color="&nonLinkColor_&" title=""上"&int_showNumberLink_&"页"">"&toP10_&"</font> " &vbNewLine
End If
If Page <> 1 and Page <>0 Then
This_Func_Get_Html_=This_Func_Get_Html_& "<a href="&toPage_&(Page-1)&" title=""上一页"">"&toP1_&"</a> " &vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_& "<font color="&nonLinkColor_&" title=""上一页"">"&toP1_&"</font> " &vbNewLine
End If
For I=StartPage To EndPage
If I=Page Then
This_Func_Get_Html_=This_Func_Get_Html_& "<b>"&I&"</b>" &vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_& "<a href="&toPage_&I&">" &I& "</a>" &vbNewLine
End If
If I<>tPageCount Then This_Func_Get_Html_=This_Func_Get_Html_& vbNewLine
Next
If Page <> Page_Rs.PageCount and Page <>0 Then
This_Func_Get_Html_=This_Func_Get_Html_& " <a href="&toPage_&(Page+1)&" title=""下一页"">"&toN1_&"</a> " &vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_& "<font color="&nonLinkColor_&" title=""下一页"">"&toN1_&"</font> " &vbNewLine
End If
If EndPage<tpagecount Then
This_Func_Get_Html_=This_Func_Get_Html_& " <a href="&toPage_& Page + NaviLength &" title=""下"&int_showNumberLink_&"页"">"&toN10_&"</a> " &vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_& " <font color="&nonLinkColor_&" title=""下"&int_showNumberLink_&"页"">"&toN10_&"</font> " &vbNewLine
End If
if Page_Rs.PageCount<>Page then
This_Func_Get_Html_=This_Func_Get_Html_& "<a href="&toPage_&Page_Rs.PageCount&" title=""尾页"">"&toL_&"</a>" &vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_& "<font color="&nonLinkColor_&" title=""尾页"">"&toL_&"</font>" &vbNewLine
End If
If showMorePageGo_Type_ = 1 then
Dim Show_Page_i
Show_Page_i = Page + 1
if Show_Page_i > tPageCount then Show_Page_i = 1
This_Func_Get_Html_=This_Func_Get_Html_& "<input type=""text"" size=""4"" maxlength=""10"" name=""Func_Input_Page"" onmouseover=""this.focus();"" onfocus=""this.value='"&Show_Page_i&"';"" onKeyUp=""value=value.replace(/[^1-9]/g,'')"" onbeforepaste=""clipboardData.setData('text',clipboardData.getData('text').replace(/[^1-9]/g,''))"">" &vbNewLine _
&"<input type=""button"" value=""Go"" onmouseover=""Func_Input_Page.focus();"" onclick=""javascript:var Js_JumpValue;Js_JumpValue=document.all.Func_Input_Page.value;if(Js_JumpValue=='' || !isNaN(Js_JumpValue)) location='"&topage_&"'+Js_JumpValue; else location='"&topage_&"1';"">" &vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_& " 跳转:<select NAME=menu1 onChange=""var Js_JumpValue;Js_JumpValue=this.options[this.selectedIndex].value;if(Js_JumpValue!='') location=Js_JumpValue;"">"
for i=1 to tPageCount
This_Func_Get_Html_=This_Func_Get_Html_& "<option value="&topage_&i
if Page=i then This_Func_Get_Html_=This_Func_Get_Html_& " selected style='color:#0000FF'"
This_Func_Get_Html_=This_Func_Get_Html_& ">第"&cstr(i)&"页</option>" &vbNewLine
next
This_Func_Get_Html_=This_Func_Get_Html_& "</select>" &vbNewLine
End if
This_Func_Get_Html_=This_Func_Get_Html_& p_&sp2_&" 每页<b>"&Page_Rs.PageSize&"</b>个记录,现在是:<b><span class=""tx"">"&sp2_&Page&"</span>/"&tPageCount&"</b>页,共<b><span id='recordcount'>"&sp2_&Page_Rs.recordCount&"</span></b>个记录。"
else
'没有记录
end if
fPageCount = This_Func_Get_Html_
End Function
%>
猜你喜欢
- 用在产品内容展示的页面上,给产品图片加上提示工具条,鼠标移动图片上即可看到效果,效果还是不错的:带黑白效果和放大图片效果(by misshj
- 使用 NetBox 可以方便的将 asp 应用编译成为独立运行的执行程序,完全摆脱 iis 的束缚,在几乎所有的 Windows 版本上面直
- 看到sam关于max-height的文章,觉得按捺不住了。sam注重于样式表的写法,过多的要求div+css的布局,sam可是追求艺术的人哦
- 昨天有位同事说,他的网页查询过程中发现普通索引和唯一索引的效率是有差别的,普通索引比唯一索引快,今天在我的虚拟机中布置了环境,测试抓图如下:
- 代码如下: <% '屏蔽主流的下载工具 Dimxurl,xtool '获取浏览器AGENT xurl=lcase(Re
- asp之家注:那么为什么要使用分页呢?当记录不多的时候,如10个或20个,我们可以也没必要使用分页来显示数据,但是数据是在不断增加的,当到了
- 用下列代码判断表单提交到服务器的数据是否有谈话内容,如果没有的话就不作处理了:if len(usersays)<>0&
- 代码如下:<html> <head> &nb
- 数据库操作类在网上一搜一大把,我这并不比那些好,只是是自己写的,用着更习惯。所以我这个类没有什么特别的地方,只是自己用着习惯罢了,至于效率等
- javascript实现翻页效果:<html> <head> <title>上下翻页看 - aspxho
- MySQL是一个非常流行的小型关系型数据库管理系统,2008年1月16号被Sun公司收购。目前MySQL被广泛地应用在Internet上的中
- 最近 W3C 一口气推出 7 个 HTML 工作草案,涵盖了 HTML5,HTML RDF,HTML Microdata,HTM
- 下面继续为大家带来XHTML与HTML兼容的16条指引!1.避免将页面声明为XML类型,页面使用UTF-8或者UTF-16字符集。2.在空元
- MySQL的本地备份和双机相互备份脚本:首先,我们需要修改脚本进行必要的配置,然后以root用户执行。◆1. 第一执行远程备份时先用 fir
- 文章主要描述的是SQL Server聚集索引的指示(Cluster Index Indications),在实际操作中借助聚集索引来进行搜索
- IE 的弹窗常用的有两种,不外乎是 window.open 与 window.showModalDialog,前者兼容性好,后者
- 请先看看以下演示中的图案文字。这可不是图片效果,而是用CSS滤镜中的Chroma() 语句做成的文本文
- 数据库连接:<% set conn=server.createobject("adodb.connection&q
- 1、先介绍如何用PHP连上数据库(数据库用户名“root”,密码“sun”,有库“myguestbook”) 图62、PHP和My
- 在本文中,此示例标准蓝图的存储过程命名方法只适用于SQL内部,假如你正在创建一个新的存储过程,或是发现一个没有按照这个标准构造的存储过程,即