请各位帮忙改改这个分页类的问题,急等(送分!)
以下这个分页类是我网上找来的,奇怪无法显示,showpage()也写错成了show(),而且其他还有问题 ,哪位达人能帮忙看看是什么原因?
<%
'============================
'XDOWNPAGE ASP版本
'版本 1.50
'
'Improved by R.Koo
'BLOG: http://www.koz.cn
'Email: koz@koz.cn
'本程序遵循“共同创作协议”,可以免费使用、修改、转载,但请保留版权请息
'本类修改自zykj2000的分页类
'
'改良内容:
'应用XHTML规则,以<ul>显示列表,
'本分页的<ul>的ID号为“page”
'如果想要横向显示,可以在CSS文件里加上 display:inline;
'快速跳页,在下拉列表里选中页码即可立即跳转
'
'
'Code by zykj2000
'Email: zykj_2000@163.net
'BBS: http://bbs.513soft.net
'本程序可以免费使用、修改,希望我的程序能为您的工作带来方便
'但请保留以上请息
'
'程序特点
'本程序主要是对数据分页的部分进行了封装,而数据显示部份完全由用户自定义,
'支持URL多个参数
'
'使用说明
'程序参数说明
'PapgeSize 定义分页每一页的记录数
'GetRS 返回经过分页的Recordset此属性只读
'GetConn 得到数据库连接
'GetSQL 得到查询语句
'程序方法说明
'ShowPage 显示分页导航条,唯一的公用方法
'
'例:
'
' '包含文件
'
' Set mypage=new xdownpage '创建对象
' mypage.getconn=conn '得到数据库连接
' mypage.getsql="select * from productinfo order by id asc"
' mypage.pagesize=5 '设置每一页的记录条数据为5条
' set rs=mypage.getrs() '返回Recordset
' mypage.showpage() '显示分页信息,这个方法可以,在set rs=mypage.getrs()以后
' 任意位置调用,可以调用多次
' for i=1 to mypage.pagesize '接下来的操作就和操作一个普通Recordset对象一样操作
' if not rs.eof then '这个标记是为了防止最后一页的溢出
' Response.Write & rs(0) & "" '这里就可以自定义显示方式了
' rs.movenext
' else
' exit for
' end if
' next
'
'============================
Class Xdownpage
Private XD_PageCount,XD_Conn,XD_Rs,XD_SQL,XD_PageSize
Private Str_errors,int_curpage,str_URL,int_totalPage,int_totalRecord
Private str_error,SW_Error
'============================
'PageSize 属性
'设置每一页的分页大小
'============================
Public Property Let PageSize(int_PageSize)
If IsNumeric(Int_Pagesize) Then
XD_PageSize=CLng(int_PageSize)
Else
str_error=str_error & "PageSize的参数不正确"
ShowError()
End If
End Property
Public Property Get PageSize
If XD_PageSize="" or (not(IsNumeric(XD_PageSize))) Then
PageSize=10
Else
PageSize=XD_PageSize
End If
End Property
'============================
'GetRS 属性
'返回分页后的记录集
'============================
Public Property Get GetRs()
Set XD_Rs=Server.createobject("adodb.recordset")
XD_Rs.PageSize=PageSize
XD_Rs.Open XD_SQL,XD_Conn,1,1
If not(XD_Rs.eof and XD_RS.BOF) Then
If int_curpage>XD_RS.PageCount Then
int_curpage=XD_RS.PageCount
End If
XD_Rs.AbsolutePage=int_curpage
End If
Set GetRs=XD_RS
End Property
'============================
'GetConn 得到数据库连接
'
'============================
Public Property Let GetConn(obj_Conn)
Set XD_Conn=obj_Conn
End Property
'============================
'GetSQL 得到查询语句
'
'============================
Public Property Let GetSQL(str_sql)
XD_SQL=str_sql
End Property
'============================
'Class_Initialize 类的初始化
'初始化当前页的值
'
'============================
Private Sub Class_Initialize
'========================
'设定一些参数的黙认值
'========================
XD_PageSize=10 '设定分页的默认值为10
'========================
'获取当前面的值
'========================
If request("page")="" Then
int_curpage=1
ElseIf not(IsNumeric(request("page"))) Then
int_curpage=1
ElseIf CInt(Trim(request("page")))<1 Then
int_curpage=1
Else
Int_curpage=CInt(Trim(request("page")))
End If
End Sub
'首页 前页 后页 尾页 页次:1/11 页 20 个记录/页 转到 1 共 201 个记录
Public Function Page()
Dim Str_tmp,str_fisrt,str_prev,str_next,str_last,str_info,str_select,i
int_totalRecord=XD_RS.RecordCount
If int_totalRecord>0 Then
'Page="暂时没有记录"
'str_error=str_error & "总记录数为零,请输入数据"
'Call ShowError()
If int_totalRecord>0 Then 'int_TotalPage=1
If int_totalRecord mod PageSize =0 Then
int_TotalPage = CLng(int_TotalRecord \ XD_PageSize )
Else
int_TotalPage = CLng(int_TotalRecord \ XD_PageSize )+1
End If
End If
If Int_curpage>int_Totalpage Then
int_curpage=int_TotalPage
End If
If int_curpage=1 Then
str_fisrt="首页"
str_prev="前页"
Else
str_fisrt="<a href="""&geturl&"1"&""">首页</a>"
str_prev="<a href="""&geturl&int_curpage-1&""">前页</a>"
End If
If int_curpage>=int_totalpage Then
str_next="后页"
str_last="尾页"
Else
str_next="<a href="""&geturl&Int_curpage+1&""">后页</a>"
str_last="<a href="""&geturl&int_totalpage&""">尾页</a>"
End If
str_select="<select onchange=""if(this.options[this.selectedIndex].value!='')"&_
"{location=this.options[this.selectedIndex].value;}"">"&vbCrLf
For i=1 to int_totalpage
str_select=str_select&"<option value="""&geturl&i&""""
if int_curpage=i then str_select=str_select&" selected=""selected""" 'str_tmp=str_tmp & "["&i&"]" else str_tmp=str_tmp & "<a href="""&geturl&i&""">["&i&"]</a>"
str_select=str_select&">"&i&"</option>"&vbCrLf
Next
str_select=str_select&"</select>"
str_info="<li>页次:<span class=""page_number"">"&Int_curpage&"</span>/<span class=""page_number"">"&int_totalpage&"</span> 页 </li><li><span class=""page_number"">"&XD_PageSize&"</span>条/页</li><li>转到"&vbCrLf&str_select&vbCrLf&"页</li><li>共<span class=""page_number"">"&int_totalrecord&"</span>个记录</li>"
page = "<li>" & str_fisrt &"</li><li>"& str_prev &"</li><li>"& str_next &"</li><li>"& str_last &"</li>"
Page = "<ul id=""page"">" & page & str_info& "</ul>" &vbCrLf
End If
End Function
'============================
'GetURL 得到当前的URL
'更据URL参数不同,获取不同的结果
'
'============================
Private Function GetURL()
Dim strurl,str_url,i,j,search_str,result_url,str_params
search_str="page="
strurl=Request.ServerVariables("URL")
Strurl=split(strurl,"/")
i=UBound(strurl,1)
str_url=strurl(i)'得到当前页文件名
str_params=Request.ServerVariables("QUERY_STRING")
If str_params="" Then
result_url=str_url & "?page="
Else
If InstrRev(str_params,search_str)=0 Then
result_url=str_url & "?" & str_params &"&page="
Else
j=InstrRev(str_params,search_str)-2
If j=-1 Then
result_url=str_url & "?page="
Else
str_params=Left(str_params,j)
result_url=str_url & "?" & str_params &"&page="
End If
End If
End If
GetURL=result_url
End Function
'============================
' 设置 Terminate 事件。
'
'============================
Private Sub Class_Terminate
XD_RS.close
Set XD_RS=nothing
End Sub
'============================
'ShowError 错误提示
'
'
'============================
Private Sub ShowError()
If str_Error <> "" Then
Response.Write ("<div align=""center"">出错了:“"&str_error&"”<BR><BR><a href=""default.asp"" title=""返回首页"">点击返回首页</a></div>")
Response.End
End If
End Sub
End class
%>