• 非常经典的asp分页案例


    <!--#include file="conn.asp"-->
    <!--#include file="admin.asp"-->
    <script language="javascript">
    function ConfirmDel()
    {
    if(confirm("确定要删除此记录吗?"))
     return true;
    else
      return false;
    }
    </script>
    <%if Request.QueryString("mark")="southidc" then
    dim SQL, Rs, contentID,CurrentPage
    CurrentPage = request("Page")
    contentID=request("id")

    set rs=server.createobject("adodb.recordset")
    sqltext="delete from Aboutus where Id="& contentID
    rs.open sqltext,conn,3,3
    set rs=nothing
    conn.close
    response.redirect "AdminAboutus.asp"
    end if
    %>
    <%

    set rs=server.createobject("adodb.recordset")
    sqltext="select * from Aboutus order by id desc"
    rs.open sqltext,conn,1,1

    dim MaxPerPage
    MaxPerPage=10
    dim text,checkpage
    text="0123456789"
    Rs.PageSize=MaxPerPage
    for i=1 to len(request("page"))
    checkpage=instr(1,text,mid(request("page"),i,1))
    if checkpage=0 then
    exit for
    end if
    next

    If checkpage<>0 then
     If NOT IsEmpty(request("page")) Then
     CurrentPage=Cint(request("page"))
     If CurrentPage < 1 Then CurrentPage = 1
     If CurrentPage > Rs.PageCount Then CurrentPage = Rs.PageCount
     Else
     CurrentPage= 1
     End If
     If not Rs.eof Then Rs.AbsolutePage = CurrentPage end if
    Else
     CurrentPage=1
    End if

    call list

    '显示帖子的子程序
    Sub list()%>
    <!-- #include file="Inc/Head.asp" -->

    <table width="556" border="0" align="center" cellpadding="2" cellspacing="1" class="table_southidc">
      <tr>
        <td width="550" height="25" class="back_southidc">
          <div align="center"><strong>栏目管理</strong></div></td>
      </tr>
      <tr>
        <td height="66">
          <div align="center">
            <table width="100%" height="62" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000" class="border">
              <tr bgcolor="#ECF5FF" class="title">
                <td width="161" align="center"><strong>排序号</strong></td>
                <td width="249" height="29" align="center"><strong> 栏目名称</strong></td>
                <td width="136" align="center"><strong> 操作</strong></td>
              </tr>
                 <%
    if not rs.eof then
    i=0
    do while not rs.eof
    %>
              <tr class="tdbg">
                <td align="center" bgcolor="#ECF5FF"><%=rs("Aboutusorder")%></td>
                <td height="28" align="center" bgcolor="#ECF5FF"><%=rs("Title")%></td>
                <td align="center" bgcolor="#ECF5FF"><a href=../Aboutus.asp?Title=<%=rs("Title")%> target="_blank">查看</a>&nbsp; &nbsp;<a href="AdminAboutusModify.asp?ID=<%=rs("ID")%>">修改</a>&nbsp; &nbsp;<a href="AdminAboutus.asp?id=<%=rs("id")%>&mark=southidc" onClick="return ConfirmDel();">删除</a></td>
              </tr>
                <%
    i=i+1
    if i >= MaxPerpage then exit do
    rs.movenext
    loop
    end if
    %>
            </table>
      
        </div></td>
     
      </tr>

         <tr><td height="25" colspan="3" bgcolor="#FFFFFF"> <div align="right">
                          <%
    Response.write "全部-"
    Response.write "共" & Cstr(Rs.RecordCount) & "篇文章&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
    Response.write "第" & Cstr(CurrentPage) &  "/" & Cstr(rs.pagecount) & "&nbsp;"
    If currentpage > 1 Then
    response.write "<a href='AdminAboutus.asp?&page="+cstr(1)+"'>&nbsp;首页&nbsp;</a>"
    Response.write "<a href='AdminAboutus.asp?page="+Cstr(currentpage-1)+"'>&nbsp;上一页&nbsp;</a>"
    Else
    Response.write "&nbsp;上一页&nbsp;"
    End if
    If currentpage < Rs.PageCount Then
    Response.write "<a href='AdminAboutus.asp?page="+Cstr(currentPage+1)+"'>&nbsp;下一页&nbsp;</a>"
    Response.write "<a href='AdminAboutus.asp?page="+Cstr(Rs.PageCount)+"'>&nbsp;尾页&nbsp;</a>"
    Else
    Response.write ""
    Response.write "&nbsp;下一页&nbsp;"
    End if
    Response.write "转到第"
    response.write"<select name='sel_page' onChange='javascript:location=this.options[this.selectedIndex].value;'>"
        for i = 1 to Rs.PageCount
           if i = currentpage then
              response.write"<option value='AdminAboutus.asp?page="&i&"&id="&id&"' selected>"&i&"</option>"
           else
              response.write"<option value='AdminAboutus.asp?page="&i&"&id="&id&"'>"&i&"</option>"
           end if
        next
    response.write"</select>页"
    %>
                        </div></td></tr>
      <%
    End sub
    rs.close

    %>
    </table>

  • 相关阅读:
    根据用户输入的工资计算所得税
    ATM取款机数据库设计
    ExecuteNonQuery()
    ExecuteReader()获得数据
    ExecuteScalar ()
    面试题汇总(三)
    面试题汇总(一)
    2019-8最新面试题汇总
    linux下vim 选择文本,删除,复制,粘贴
    TCP和UDP的优缺点及区别
  • 原文地址:https://www.cnblogs.com/coderblog/p/1236218.html
Copyright © 2020-2023  润新知