Func_Page.asp
上传用户:jisenq
上传日期:2014-06-29
资源大小:7216k
文件大小:7k
源码类别:

数据库编程

开发平台:

ASP/ASPX

  1. <%''++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. ''调用例子 code by awen ueuo.cn 最好的网络收藏夹
  3. 'Dim int_RPP,int_Start,int_showNumberLink_,str_nonLinkColor_,toF_,toP10_,toP1_,toN1_,toN10_,toL_,showMorePageGo_Type_,cPageNo
  4. 'int_RPP=2 '设置每页显示数目
  5. 'int_showNumberLink_=8 '数字导航显示数目
  6. 'showMorePageGo_Type_ = 1 '是下拉菜单还是输入值跳转,当多次调用时只能选1
  7. 'str_nonLinkColor_="#999999" '非热链接颜色
  8. 'toF_="<font face=webdings>9</font>"   '首页 
  9. 'toP10_=" <font face=webdings>7</font>" '上十
  10. 'toP1_=" <font face=webdings>3</font>" '上一
  11. 'toN1_=" <font face=webdings>4</font>" '下一
  12. 'toN10_=" <font face=webdings>8</font>" '下十
  13. 'toL_="<font face=webdings>:</font>" '尾页
  14. '============================================
  15. '这段代码一定要在VClass_Rs.Open 与 for循环之间
  16. ' Set VClass_Rs = CreateObject(G_FS_RS)
  17. ' VClass_Rs.Open This_Fun_Sql,User_Conn,1,1
  18. ' IF not VClass_Rs.eof THEN 
  19. ' VClass_Rs.PageSize=int_RPP
  20. ' cPageNo=NoSqlHack(Request.QueryString("Page"))
  21. ' If cPageNo="" Then cPageNo = 1
  22. ' If not isnumeric(cPageNo) Then cPageNo = 1
  23. ' cPageNo = Clng(cPageNo)
  24. ' If cPageNo<=0 Then cPageNo=1
  25. ' If cPageNo>VClass_Rs.PageCount Then cPageNo=VClass_Rs.PageCount 
  26. ' VClass_Rs.AbsolutePage=cPageNo
  27. '   FOR int_Start=1 TO int_RPP 
  28.   ''++++++++++
  29.   '加循环体显示数据
  30.   ''++++++++++
  31. ' VClass_Rs.MoveNext
  32. ' if VClass_Rs.eof or VClass_Rs.bof then exit for
  33. '      NEXT
  34. ' END IF   
  35. '============================================
  36. 'response.Write "<p>"&  fPageCount(VClass_Rs,int_showNumberLink_,str_nonLinkColor_,toF_,toP10_,toP1_,toN1_,toN10_,toL_,showMorePageGo_Type_,cPageNo)
  37. ''++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  38. '*********************************************************
  39. ' 目的:分页的页面参数保持
  40. '          提交查询的一致性
  41. ' 输入:moveParam:分页参数
  42. '         removeList:要移除的参数
  43. ' 返回:分页Url
  44. '*********************************************************
  45. Function PageUrl(moveParam,removeList)
  46. dim strName
  47. dim KeepUrl,KeepForm,KeepMove
  48. removeList=removeList&","&moveParam
  49. KeepForm=""
  50. For Each strName in Request.Form 
  51. '判断form参数中的submit、空值
  52. if not InstrRev(","&removeList&",",","&strName&",", -1, 1)>0 and Request.Form(strName)<>"" then
  53. KeepForm=KeepForm&"&"&strName&"="&Server.URLencode(Request.Form(strName))
  54. end if
  55. removeList=removeList&","&strName
  56. Next
  57. KeepUrl=""
  58. For Each strName In Request.QueryString
  59. If not (InstrRev(","&removeList&",",","&strName&",", -1, 1)>0) Then
  60. KeepUrl = KeepUrl & "&" & strName & "=" & Server.URLencode(Request.QueryString(strName))
  61. End If
  62. Next
  63. KeepMove=KeepForm&KeepUrl
  64. If (KeepMove <> "") Then 
  65.   KeepMove = Right(KeepMove, Len(KeepMove) - 1)
  66.   KeepMove = Server.HTMLEncode(KeepMove) & "&"
  67. End If
  68. 'PageUrl = replace(Request.ServerVariables("URL"),"/Search.asp","/Search.html") & "?" & KeepMove & moveParam & "="
  69. PageUrl =  "?" & KeepMove & moveParam & "="
  70. End Function 
  71. Function fPageCount(Page_Rs,showNumberLink_,nonLinkColor_,toF_,toP10_,toP1_,toN1_,toN10_,toL_,showMorePageGo_Type_,Page)
  72. Dim This_Func_Get_Html_,toPage_,p_,sp2_,I,tpagecount
  73. Dim NaviLength,StartPage,EndPage
  74. This_Func_Get_Html_ = ""  : I = 1   
  75. NaviLength=showNumberLink_ 
  76. if IsEmpty(showMorePageGo_Type_) then showMorePageGo_Type_ = 1
  77. tpagecount=Page_Rs.pagecount
  78. If tPageCount<1 Then tPageCount=1 
  79. if not Page_Rs.eof or not Page_Rs.bof then
  80. toPage_ = PageUrl("Page","submit,GetType,no-cache,_")
  81. if Page=1 then 
  82. This_Func_Get_Html_=This_Func_Get_Html_& "<font color="&nonLinkColor_&" title=""首页"">"&toF_&"</font> " &vbNewLine
  83. Else 
  84. This_Func_Get_Html_=This_Func_Get_Html_& "<a href="&toPage_&"1 title=""首页"">"&toF_&"</a> " &vbNewLine
  85. End If 
  86. if Page<NaviLength then
  87. StartPage = 1
  88. else
  89. StartPage = fix(Page / NaviLength) * NaviLength
  90. end if
  91. EndPage=StartPage+NaviLength-1 
  92. If EndPage>tPageCount Then EndPage=tPageCount 
  93. If StartPage>1 Then 
  94. This_Func_Get_Html_=This_Func_Get_Html_& "<a href="&toPage_& Page - NaviLength &" title=""上"&int_showNumberLink_&"页"">"&toP10_&"</a> "  &vbNewLine
  95. Else 
  96. This_Func_Get_Html_=This_Func_Get_Html_& "<font color="&nonLinkColor_&" title=""上"&int_showNumberLink_&"页"">"&toP10_&"</font> "  &vbNewLine
  97. End If 
  98. If Page <> 1 and Page <>0 Then 
  99. This_Func_Get_Html_=This_Func_Get_Html_& "<a href="&toPage_&(Page-1)&"  title=""上一页"">"&toP1_&"</a> "  &vbNewLine
  100. Else 
  101. This_Func_Get_Html_=This_Func_Get_Html_& "<font color="&nonLinkColor_&" title=""上一页"">"&toP1_&"</font> "  &vbNewLine
  102. End If 
  103. For I=StartPage To EndPage 
  104. If I=Page Then 
  105. This_Func_Get_Html_=This_Func_Get_Html_& "<b>"&I&"</b>"  &vbNewLine
  106. Else 
  107. This_Func_Get_Html_=This_Func_Get_Html_& "<a href="&toPage_&I&">" &I& "</a>"  &vbNewLine
  108. End If 
  109. If I<>tPageCount Then This_Func_Get_Html_=This_Func_Get_Html_& vbNewLine
  110. Next 
  111. If Page <> Page_Rs.PageCount and Page <>0 Then 
  112. This_Func_Get_Html_=This_Func_Get_Html_& " <a href="&toPage_&(Page+1)&" title=""下一页"">"&toN1_&"</a> "  &vbNewLine
  113. Else 
  114. This_Func_Get_Html_=This_Func_Get_Html_& "<font color="&nonLinkColor_&" title=""下一页"">"&toN1_&"</font> "  &vbNewLine
  115. End If 
  116. If EndPage<tpagecount Then  
  117. This_Func_Get_Html_=This_Func_Get_Html_& " <a href="&toPage_& Page + NaviLength &"  title=""下"&int_showNumberLink_&"页"">"&toN10_&"</a> "  &vbNewLine
  118. Else 
  119. This_Func_Get_Html_=This_Func_Get_Html_& " <font color="&nonLinkColor_&"  title=""下"&int_showNumberLink_&"页"">"&toN10_&"</font> "  &vbNewLine
  120. End If 
  121. if Page_Rs.PageCount<>Page then  
  122. This_Func_Get_Html_=This_Func_Get_Html_& "<a href="&toPage_&Page_Rs.PageCount&" title=""尾页"">"&toL_&"</a>"  &vbNewLine
  123. Else 
  124. This_Func_Get_Html_=This_Func_Get_Html_& "<font color="&nonLinkColor_&" title=""尾页"">"&toL_&"</font>"  &vbNewLine
  125. End If 
  126. If showMorePageGo_Type_ = 1 then 
  127. Dim Show_Page_i
  128. Show_Page_i = Page + 1
  129. if Show_Page_i > tPageCount then Show_Page_i = 1
  130. 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 _
  131. &"<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
  132. Else 
  133. 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;"">"
  134. for i=1 to tPageCount
  135. This_Func_Get_Html_=This_Func_Get_Html_& "<option value="&topage_&i
  136. if Page=i then This_Func_Get_Html_=This_Func_Get_Html_& " selected style='color:#0000FF'"
  137. This_Func_Get_Html_=This_Func_Get_Html_& ">第"&cstr(i)&"页</option>" &vbNewLine
  138. next
  139. This_Func_Get_Html_=This_Func_Get_Html_& "</select>" &vbNewLine
  140. End if
  141. This_Func_Get_Html_=This_Func_Get_Html_& p_&sp2_&" &nbsp;每页<b>"&Page_Rs.PageSize&"</b>个记录,现在是:<b><span class=""tx"">"&sp2_&Page&"</span>/"&tPageCount&"</b>页,共<b><span id='recordcount'>"&sp2_&Page_Rs.recordCount&"</span></b>个记录。"
  142. else
  143. '没有记录
  144. end if
  145. fPageCount = This_Func_Get_Html_
  146. End Function
  147. %>