• 分页函数和如何调用分页数据函数?


    '-------------------------------------------------
    'PageSize:每页的纪录数
    'tmpPageNo:第几页
    'PageCount:总页数
    'FileName:分页的asp文件
    'Param:传递的参数
    '----------------------------------------------------

    Function getPageUpDownInfo(PageSize, tmpPageNo, PageCount, FileName, Param)
     dim strTemp
     dim PageNo

     if tmpPageNo = "" or not IsNumeric(tmpPageNo) then
      PageNo = 1
     else
      PageNo = CLng(tmpPageNo)

      if PageNo > PageCount then
       PageNo = PageCount
      end if
     end if

    ' strTemp = strTemp & "<table align='center'><tr><td>" & chr(13)
     strTemp = strTemp & CStr(pageNo) & "<font color='#8A8A8A'>/" & CStr(PageCount) & "页" & chr(13)
     strTemp = strTemp & "&nbsp;"
     if Param = "" then
      if PageNo <= 1 then
       strTemp = strTemp & "首页" & chr(13)
       strTemp = strTemp & "&nbsp;"
       strTemp = strTemp & "前页" & chr(13)
      else
       strTemp = strTemp & "<a href='" & FileName & "?" & "PageNo=1&PageSize=" & PageSize & "'>首页</a>" & chr(13)
       strTemp = strTemp & "&nbsp;"
       strTemp = strTemp & "<a href='" & FileName & "?" & "PageNo=" & CStr(PageNo - 1) & "&PageSize=" & PageSize & "'>前页</a>" & chr(13)
      end if
      strTemp = strTemp & "&nbsp;"
      if PageNo = PageCount then
       strTemp = strTemp & "后页" & chr(13)
       strTemp = strTemp & "&nbsp;"
       strTemp = strTemp & "尾页" & chr(13)
      else
       strTemp = strTemp & "<a href='" & FileName & "?" & "PageNo=" & CStr(PageNo + 1) & "&PageSize=" & PageSize & "'>后页</a>" & chr(13)
       strTemp = strTemp & "&nbsp;"
       strTemp = strTemp & "<a href='" & FileName & "?" & "PageNo=" & CStr(PageCount) & "&PageSize=" & PageSize & "'>尾页</a>" & chr(13)
      end if
     else
      if PageNo <= 1 then
       strTemp = strTemp & "首页" & chr(13)
       strTemp = strTemp & "&nbsp;"
       strTemp = strTemp & "前页" & chr(13)
      else
       strTemp = strTemp & "<a href='" & FileName & "?" & Param & "&PageNo=1&PageSize=" & PageSize & "'>首页</a>" & chr(13)
       strTemp = strTemp & "&nbsp;"
       strTemp = strTemp & "<a href='" & FileName & "?" & Param & "&PageNo=" & CStr(PageNo - 1) & "&PageSize=" & PageSize & "'>前页</a>" & chr(13)
      end if
      strTemp = strTemp & "&nbsp;"
      if PageNo = PageCount then
       strTemp = strTemp & "后页" & chr(13)
       strTemp = strTemp & "&nbsp;"
       strTemp = strTemp & "尾页" & chr(13)
      else
       strTemp = strTemp & "<a href='" & FileName & "?" & Param & "&PageNo=" & CStr(PageNo + 1) & "&PageSize=" & PageSize & "'>后页</a>" & chr(13)
       strTemp = strTemp & "&nbsp;"
       strTemp = strTemp & "<a href='" & FileName & "?" & Param & "&PageNo=" & CStr(PageCount) & "&PageSize=" & PageSize & "'>尾页</a>" & chr(13)
      end if
     end if
     strTemp = strTemp & "</font>" & chr(13)
    ' strTemp = strTemp & "</td></tr></table>" & chr(13)

     getPageUpDownInfo = strTemp
    end function

    结合函数GetListByPage(strSQL, PageSize, PageNo, PageCount, arrList)和函数getPageUpDownInfo(PageSize, tmpPageNo, PageCount, FileName, Param)分页的例子


    <%
    dim strSQL, arrList
    dim PageSize, PageNo, PageCount
    dim strTemp

    strTemp = Trim(Request("PageSize"))
    if strTemp = "" or not IsNumeric(strTemp) then
        PageSize = 15
    else
        PageSize = CLng(strTemp)
    end if
    strTemp = Trim(Request("PageNo"))
    if strTemp = "" or not IsNumeric(strTemp) then
        PageNo = 1
    else
        PageNo = CLng(strTemp)
    end if

    intID = cInt(Request("ID"))
    %>


    <table width="100%"  border="0" cellspacing="20" cellpadding="0">
            <tr>
              <td>
        <table width="100%"  border="0" cellpadding="0" cellspacing="1">
                <tr>
                  <td width="30" bgcolor="#FFC277">&nbsp;</td>
                  <td height="22" align="center" bgcolor="#FFAE4A" class="wh">新 闻 标 题</td>
                  <td width="100" align="center" bgcolor="#FFC277" class="wh">发 布 时 间</td>
                </tr>
    <%
        strSQL = "select * from News WHERE ID=" & intID & "  order by ID Desc"
        if GetList(strSQL, PageSize, PageNo, PageCount, arrList) then
       for i = 0 to ubound(arrList, 2)
    %>
                <tr>
                  <td align="center" background="images/sub_bg2.gif"><font color="#29BECE">·</font></td>
                  <td height="25" background="images/sub_bg2.gif"><A class=a2 href="/ReadNews.asp?id=<%=arrList(0, i)%>&ID=<%=arrList(1, i)%>" title="<%=arrList(2, i)%>" target=_blank><%=arrList(2, i)%></A></td>
                  <td height="25" background="images/sub_bg2.gif" class="link01">[<%=FormatDateTime(arrList(4, i),vbShortDate)%>]</td>
                </tr>
    <%
          next
        else
       Response.write "<tr><td colspan='3' align='center'>暂时没有数据。</td></tr>"
        end if
    %>
              </table>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
           <td height="22" align="Right" bgcolor="#FFAE4A" class="wh"><%=getPageUpDownInfo(PageSize, PageNo, PageCount, "List.asp", " ID="&intID)%>&nbsp;&nbsp;&nbsp;</td>
                  </tr>
                </table>



  • 相关阅读:
    如何正确的学习?
    GitHub的使用
    freemarker
    Vue的前端路由
    推荐一个压缩图片好用的网站-tinyPNG
    纯CSS实现滚动彩虹色文字
    npm镜像源管理
    UI、UE和UX三者之间的区别?
    移动端rem布局的学习(基于一个网易云播放页面的思考)
    移动前端不得不了解的html5 head 头标签
  • 原文地址:https://www.cnblogs.com/stronger/p/210580.html
Copyright © 2020-2023  润新知