如何在Active Server Page上实现Paging(ASP Classic)

时间:2022-08-29 01:54:37

I have done an Active Server Page. It is running on a foyerdisplay and displays Meeting. I limited the displaying meetings to 6. I have 15 meetings in my Database. But the foyerdisplay can display only 6 meetings at a time. To Display the rest of the meetings i want to implement Paging, but i dont know how.

我做了一个Active Server Page。它在foyerdisplay上运行并显示Meeting。我将显示会议限制为6.我在我的数据库中有15次会议。但是,门厅显示器一次只能显示6个会议。要显示我希望实现分页的其余会议,但我不知道如何。

The Paging should happen automatically. For example: Displaying the first 6 meeting for 10 sec, then 10 sec the next 6 meeting, then 10 sec the last 3 meetings and then again the first 6 meetings and so on.

分页应该自动发生。例如:显示前6个会议10秒,然后10秒,接下来的6个会议,然后10秒,最后3个会议,然后再显示前6个会议,依此类推。

Can anyone help me with that? I have no idea how to do that. Thanks!

任何人都可以帮助我吗?我不知道该怎么做。谢谢!

 <%
    set rs=Server.CreateObject("ADODB.recordset")
    set rsRaum=Server.CreateObject("ADODB.recordset")

    rs.Open "select distinct buchung_id, von, bis, abteilung, veranstalter, THEMA, THEMA_ENABLED " & _
            "  from RESERVIERUNGRAUM r  " & _
            "      ,BUCHUNG b  " & _
            " where r.BUCHUNG_ID = b.ID " & _
            "   and von >= convert(date, getdate(), 4) " & _
            "   and von < convert(date, dateadd(day,1, GETDATE()), 4) " & _
            "   and BIS >= getdate() " & _
            "   and STORNO is null  " & _
            " order by von, bis" _
           ,objConn 


    lineMax = 6
    lineCount = 1
    do until rs.EOF



      rsRaum.open "select DISPLAY_ENABLED from Buchung where ID = " & rs("buchung_id"), objConn
                displayanzeige = rsRaum("DISPLAY_ENABLED")
      rsRaum.close


      rsRaum.open      "select distinct g.BEZEICHNUNG " & _
                       "from GEBAEUDE g, ETAGE e, RAUM r " & _
                       "Where g.ID = e.GEBAEUDE_ID and e.GEBAEUDE_ID = r.GEBAEUDE_ID and r.ID = " & raum_id, objConn

                       GebaeudeBezeichnung = rsRaum("BEZEICHNUNG")

      rsRaum.close



      rsRaum.open "select bezeichnung from Raum where ID = " & raum_id, objConn

          raumname = rsRaum("bezeichnung")

      rsRaum.close

      If lineCount > lineMax Then
        exit do
      End If 


      if ucase(displayanzeige) = "Y" or isnull(displayanzeige) then
    %>

'

<tr "margin-bottom:100px" height="70" valign="top">
    <td style="overflow:hidden;" class="<% =color%>"><% =thema %></td>
    <td class="<% =color%>"><% =Hinweistext %></td>
    <td align="center"; class="<% =color%>"><% =FormatDateTime( rs("von"), 4)%></td>
    <td align="center"; class="<% =color%>"><% =FormatDateTime( rs("bis"), 4) %></td>
    <td align="center"; class="<% =color%>"><% =GebaeudeBezeichnung %><br></td>
    <td align="center"; class="<% =color%>"><% =raumname %><br></td>
  </tr>

'

<%  

rs.moveNext

loop
rs.close 
%>

2 个解决方案

#1


4  

You'll need to do a couple of things:

你需要做几件事:

  1. Enable your script to take a GET parameter which specifies which "page" to show. Something like:

    使脚本能够获取GET参数,该参数指定要显示的“页面”。就像是:

    dim page = Request.QueryString("page")
    dim next_page = page + 1
    dim num_pages = [ you'll want to get this from your database table ]
    
  2. Modify your database query to use the new variable page appropriately

    修改数据库查询以适当地使用新变量页面

  3. Generate some javascript on the page which will cause the browser to load up a new URL for the next page after 10 seconds. If it's more than the total number of pages, wrap back to the start.

    在页面上生成一些javascript,这将导致浏览器在10秒后为下一页加载新的URL。如果它超过总页数,请回到开头。

    <script type="text/javascript">
    function doNextPage(){
      window.location = "/my/display.asp?page=<% Response.Write next_page mod num_pages %>";
    }
    function doNextPageDelayed(){
      setTimeout("doNextPage()", 10000);
    }
    </script>
    
  4. You'll also need to cause the function "doNextPageDelayed" to actually run. To do this, insert some code into the body tag of your HTML.

    您还需要使函数“doNextPageDelayed”实际运行。为此,请将一些代码插入HTML的body标记中。

    <body onload="doNextPageDelayed()">
    </body>
    

I found this link helpful trying to remember how to cause a delay on running a javascript function: http://www.geekpedia.com/KB55_How-do-I-make-a-JavaScript-function-wait-before-executing-(sleep-or-delay).html

我发现此链接有助于记住如何延迟运行javascript函数:http://www.geekpedia.com/KB55_How-do-I-make-a-JavaScript-function-wait-before-executing-(休眠或延迟)。html的

#2


2  

Better if you see a working example... the whole page. Only it's too much code to indent here. See the attached file... pagination

如果你看到一个有效的例子......整个页面会更好。只有在这里缩进的代码太多了。请参阅附件...分页

This example also includes sortable columns and row deletion with the option of selecting all rows on a page.

此示例还包括可排序列和行删除,并可选择选择页面上的所有行。

#1


4  

You'll need to do a couple of things:

你需要做几件事:

  1. Enable your script to take a GET parameter which specifies which "page" to show. Something like:

    使脚本能够获取GET参数,该参数指定要显示的“页面”。就像是:

    dim page = Request.QueryString("page")
    dim next_page = page + 1
    dim num_pages = [ you'll want to get this from your database table ]
    
  2. Modify your database query to use the new variable page appropriately

    修改数据库查询以适当地使用新变量页面

  3. Generate some javascript on the page which will cause the browser to load up a new URL for the next page after 10 seconds. If it's more than the total number of pages, wrap back to the start.

    在页面上生成一些javascript,这将导致浏览器在10秒后为下一页加载新的URL。如果它超过总页数,请回到开头。

    <script type="text/javascript">
    function doNextPage(){
      window.location = "/my/display.asp?page=<% Response.Write next_page mod num_pages %>";
    }
    function doNextPageDelayed(){
      setTimeout("doNextPage()", 10000);
    }
    </script>
    
  4. You'll also need to cause the function "doNextPageDelayed" to actually run. To do this, insert some code into the body tag of your HTML.

    您还需要使函数“doNextPageDelayed”实际运行。为此,请将一些代码插入HTML的body标记中。

    <body onload="doNextPageDelayed()">
    </body>
    

I found this link helpful trying to remember how to cause a delay on running a javascript function: http://www.geekpedia.com/KB55_How-do-I-make-a-JavaScript-function-wait-before-executing-(sleep-or-delay).html

我发现此链接有助于记住如何延迟运行javascript函数:http://www.geekpedia.com/KB55_How-do-I-make-a-JavaScript-function-wait-before-executing-(休眠或延迟)。html的

#2


2  

Better if you see a working example... the whole page. Only it's too much code to indent here. See the attached file... pagination

如果你看到一个有效的例子......整个页面会更好。只有在这里缩进的代码太多了。请参阅附件...分页

This example also includes sortable columns and row deletion with the option of selecting all rows on a page.

此示例还包括可排序列和行删除,并可选择选择页面上的所有行。