Bashud
Bashud

Reputation: 276

How can i implement Paging on a Active Server Page (ASP Classic)

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.

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.

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 
%>

Upvotes: 3

Views: 1762

Answers (1)

Mike Sandford
Mike Sandford

Reputation: 1365

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:

    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.

    <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.

    <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

Upvotes: 4

Related Questions