ASP AJAX 静态分页

 更新时间:2009年01月08日 17:36:21   作者:  
这个页面注意是调用来自数据库中的数据。

asp数据库读取页面
复制代码 代码如下:

<!--#include file="conn.asp"-->

<%
'Dim pagesize
'sql="select top 1 * from [pagesize] order by id desc"
'rs.open sql,conn,1,1
'pagesize=rs("pagesize")
'rs.Close
If session("pagesize")="" Then session("pagesize")=9
Dim page
page=unescape(Request.QueryString("page"))
If page<>"" Then
    sql="select * from [test] order by id asc"
    rs.open sql,conn,1,1
    If rs.eof Then
        Response.Write(escape("还没有任何数据"))
    Else
        rs.pagesize=session("pagesize")
        page=CLng(page)
        If page<1 Then
            page=1
        ElseIf page>rs.pagecount Then
            page=rs.pagecount
        End If
        rs.absolutepage=page
        Dim i,str
        str=str & "<div style='margin:0'>"
        For i=1 To rs.pagesize
            str=str & rs("id") & ". <a href='" & rs("weburl") & "' title='前往该网站' target='_blank'>" & rs("webname") & "</a><br />"
            rs.movenext
            If rs.eof Then Exit For
        Next
        str=str & "</div><div style='margin-top:10px;line-height:30px;text-align:left;border-top:1px #999 solid'>"
        str=str & "<a href='javascript:void(getweblist(1))'><<</a> "
        For i=1 To rs.pagecount
            If i=page Then
                str=str & "<span style='font-weight:bold;color:red;font-size:16px;'>" & i & "</span> "
            Else
                str=str & "<a href=javascript:void(getweblist(" & i & "))>" & i & "</a> "
            End If
        Next
        str=str & " <a href='javascript:void(getweblist(" & rs.pagecount & "))'>>></a>"
        str=str & "</div>"
        str=escape(str)
        Response.Write(str)
    End If    
    rs.Close
    Set rs=Nothing
    conn.Close
    Set conn=Nothing
Else
    Response.Write(escape("Error:页数不能为空!"))
End If
%> 

打包下载地址 https://www.jb51.net/codes/10094.html

相关文章

最新评论