0

我有一个活动服务器页面,显示当天的预订。我将 PageSize 设置为 2,因此如果有更多记录,我的显示器每边仅显示 2 个预订。所以实际上我的记录集中有 8 个预订,所以我的 ASP 创建了 4 个页面。

我写了以下函数:

Function getNext10(num)


getNext10 = CurrPage + 1


End Function

最后,我在元标记中调用该函数,以自动更改页面:

<meta http-equiv="refresh" content="10;URL=paging.asp?PageNo=<% Response.Write(getNext10(CurrPage))%>" />

它就像魅力一样工作。但我还有一个问题。如果我这样做,PageNo 将无限增加。我的页数是 4。

所以我在我的函数中需要一个逻辑来检查是否达到了 PageCount。如果是,那么他应该再次从第一页开始,如果不是,则增加直到达到 pagecount。

有人可以帮我吗?谢谢!!

编辑:

我写了那个函数:

Function getNext10(num)


 getNext10 = num

 if getNext10 < i then  // In `i`, i have my pagecount (4), which i got from Recordset.PageCount
                        // I checked it with Response.Write()
 getNext10 = CurrPage + 1


 End if

 End Function

如果我使用iif 子句不起作用,我不知道为什么。只有当我直接使用数字时它才有效。

4

1 回答 1

1

如果您知道页码将始终为 4,那么您可以进行检查。

Function getNext10(num)
   if (num < i) then
      CurrPage = num + 1
   else
      CurrPage = 1 'Reset the page count
   end if
   'Updating the variable used to call the page iterator
   getNext10 = CurrPage
End Function

如果您并不总是知道页码,那么您将需要以某种方式计算页数以进行检查。

于 2012-12-11T13:26:42.190 回答