标题: asp中可以保存参数值的分页代码
问天
元帅
Rank: 1


元帅勋章 终身成就勋章
UID 11493
精华 187
积分 34221
帖子 33355
威望 91
金币 13148
热心 2619
阅读权限 100
注册 2006-4-7
状态 离线
asp中可以保存参数值的分页代码

<%''                                                      
''调用例子
'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>"&;amp;  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&;amp;","&;amp;moveParam
KeepForm=""
For Each strName in Request.Form
  '判断form参数中的submit、空值
  if not InstrRev(","&;amp;removeList&;amp;",",","&;amp;strName&;amp;",", -1, 1)>0 and Request.Form(strName)<>"" then
   KeepForm=KeepForm&;amp;"&;amp;"&;amp;strName&;amp;"="&;amp;Server.URLencode(Request.Form(strName))
  end if
  removeList=removeList&;amp;","&;amp;strName
Next
   
KeepUrl=""
For Each strName In Request.QueryString
  If not (InstrRev(","&;amp;removeList&;amp;",",","&;amp;strName&;amp;",", -1, 1)>0) Then
   KeepUrl = KeepUrl &;amp; "&;amp;" &;amp; strName &;amp; "=" &;amp; Server.URLencode(Request.QueryString(strName))
  End If
Next

KeepMove=KeepForm&;amp;KeepUrl

If (KeepMove <> "") Then
   KeepMove = Right(KeepMove, Len(KeepMove) - 1)
   KeepMove = Server.HTMLEncode(KeepMove) &;amp; "&;amp;"
End If

'PageUrl = replace(Request.ServerVariables("URL"),"/Search.asp","/Search.html") &;amp; "?" &;amp; KeepMove &;amp; moveParam &;amp; "="
PageUrl =  "?" &;amp; KeepMove &;amp; moveParam &;amp; "="
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_&;amp; "<font color="&;amp;nonLinkColor_&;amp;" title=""首页"">"&;amp;toF_&;amp;"</font> " &;amp;vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_&;amp; "<a href="&;amp;toPage_&;amp;"1 title=""首页"">"&;amp;toF_&;amp;"</a> " &;amp;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_&;amp; "<a href="&;amp;toPage_&;amp; Page - NaviLength &;amp;" title=""上"&;amp;int_showNumberLink_&;amp;"页"">"&;amp;toP10_&;amp;"</a> "  &;amp;vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_&;amp; "<font color="&;amp;nonLinkColor_&;amp;" title=""上"&;amp;int_showNumberLink_&;amp;"页"">"&;amp;toP10_&;amp;"</font> "  &;amp;vbNewLine
End If      
If Page <> 1 and Page <>0 Then
This_Func_Get_Html_=This_Func_Get_Html_&;amp; "<a href="&;amp;toPage_&;amp;(Page-1)&;amp;"  title=""上一页"">"&;amp;toP1_&;amp;"</a> "  &;amp;vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_&;amp; "<font color="&;amp;nonLinkColor_&;amp;" title=""上一页"">"&;amp;toP1_&;amp;"</font> "  &;amp;vbNewLine
End If      
For I=StartPage To EndPage
If I=Page Then
  This_Func_Get_Html_=This_Func_Get_Html_&;amp; "<b>"&;amp;I&;amp;"</b>"  &;amp;vbNewLine
Else
  This_Func_Get_Html_=This_Func_Get_Html_&;amp; "<a href="&;amp;toPage_&;amp;I&;amp;">" &;amp;I&;amp; "</a>"  &;amp;vbNewLine
End If
If I<>tPageCount Then This_Func_Get_Html_=This_Func_Get_Html_&;amp; vbNewLine
Next     
If Page <> Page_Rs.PageCount and Page <>0 Then
This_Func_Get_Html_=This_Func_Get_Html_&;amp; " <a href="&;amp;toPage_&;amp;(Page 1)&;amp;" title=""下一页"">"&;amp;toN1_&;amp;"</a> "  &;amp;vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_&;amp; "<font color="&;amp;nonLinkColor_&;amp;" title=""下一页"">"&;amp;toN1_&;amp;"</font> "  &;amp;vbNewLine
End If     
If EndPage<tpagecount Then  
This_Func_Get_Html_=This_Func_Get_Html_&;amp; " <a href="&;amp;toPage_&;amp; Page   NaviLength &;amp;"  title=""下"&;amp;int_showNumberLink_&;amp;"页"">"&;amp;toN10_&;amp;"</a> "  &;amp;vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_&;amp; " <font color="&;amp;nonLinkColor_&;amp;"  title=""下"&;amp;int_showNumberLink_&;amp;"页"">"&;amp;toN10_&;amp;"</font> "  &;amp;vbNewLine
End If      
if Page_Rs.PageCount<>Page then  
This_Func_Get_Html_=This_Func_Get_Html_&;amp; "<a href="&;amp;toPage_&;amp;Page_Rs.PageCount&;amp;" title=""尾页"">"&;amp;toL_&;amp;"</a>"  &;amp;vbNewLine
Else
This_Func_Get_Html_=This_Func_Get_Html_&;amp; "<font color="&;amp;nonLinkColor_&;amp;" title=""尾页"">"&;amp;toL_&;amp;"</font>"  &;amp;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_&;amp; "<input type=""text"" size=""4"" maxlength=""10"" name=""Func_Input_Page"" onmouseover=""this.focus();"" onfocus=""this.value='"&;amp;Show_Page_i&;amp;"';"" onKeyUp=""value=value.replace(/[^1-9]/g,'')"" onbeforepaste=""clipboardData.setData('text',clipboardData.getData('text').replace(/[^1-9]/g,''))"">" &;amp;vbNewLine _
  &;amp;"<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='"&;amp;topage_&;amp;"' Js_JumpValue; else location='"&;amp;topage_&;amp;"1';"">"  &;amp;vbNewLine      
Else     
This_Func_Get_Html_=This_Func_Get_Html_&;amp; " 跳转:<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_&;amp; "<option value="&;amp;topage_&;amp;i
  if Page=i then This_Func_Get_Html_=This_Func_Get_Html_&;amp; " selected style='color:#0000FF'"
  This_Func_Get_Html_=This_Func_Get_Html_&;amp; ">第"&;amp;cstr(i)&;amp;"页</option>" &;amp;vbNewLine
next
This_Func_Get_Html_=This_Func_Get_Html_&;amp; "</select>" &;amp;vbNewLine      
End if      
This_Func_Get_Html_=This_Func_Get_Html_&;amp; p_&;amp;sp2_&;amp;" &;amp;nbsp;每页<b>"&;amp;Page_Rs.PageSize&;amp;"</b>个记录,现在是:<b><span class=""tx"">"&;amp;sp2_&;amp;Page&;amp;"</span>/"&;amp;tPageCount&;amp;"</b>页,共<b><span id='recordcount'>"&;amp;sp2_&;amp;Page_Rs.recordCount&;amp;"</span></b>个记录。"   
else
'没有记录
end if
fPageCount = This_Func_Get_Html_
End Function
%>
http://blog.csdn.net/hzf100/archive/2006/12/28/1465471.aspx

网友 问天 签名 - 网友社区 请您回个帖。谢谢
PR查询 免费域名 免费空间
顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-11-23 17:16
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP