[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

ASP page turner

Hello experts,

I am trying to do a page turner for an app i am working, on, i had a bit of code, but i have had to change it to suit my site, but now unfortunately, it no longer works properly. The code was writtent to serach throughtthe database and display all records but i amedned the code to dispaly records where critera = variable. This is the problem I have;

if i get for example;

page << 1 of 3 >> for a set of records. and then clikck next >> to go to next record, it then becomes page << 2 of 7 >>.

CODESS BELOW.

ORIGINAL CODE:

Function owPreserve(owVariable,owDefault)
      owTemp = Request.QueryString(owVariable)
            'If the querystring contains any data it is counted as a variable change, if not the old variable is taken from the session or the default assigned
            If Len(owTemp) = 0 Then
                  If Len(Session("user_"&owVariable)) > 0 Then
                        owTemp = Session("user_"&owVariable)
                  Else
                        owTemp = owDefault
                  End If
            End If
      Session("user_"&owVariable) = owTemp
      owPreserve = owTemp
End Function

viewRange = owPreserve("range",1)
varCurPage = owPreserve("page",1)
%>

      <%
globalPageSize = 5
oRs.cursorlocation=3
oRs.cachesize=5

If PageAction = "results" Then
      'Builds the magical search sql query
Else      
      Sql = "SELECT * FROM [product] WHERE [range]="&viewRange&" AND [active]"
End If
oRs.Open Sql, oCn

If Not oRs.Eof Then
      oRs.MoveFirst
       oRs.PageSize = globalPageSize      

      maxpages = cint(oRs.pagecount)
      
      If cint(varCurPage) > maxpages Then
            varCurPage = 1
      End If
      
      oRs.AbsolutePage = varCurPage
      nexpage = varCurPage + 1
      prepage = varCurPage - 1
      Else
            varCurPage = 1
      End If

Do While Not oRs.Eof And Not curRecord = oRs.PageSize

tId = oRs("id")
tTitle = oRs("title")
tFeatures = oRs("features")
tImage = oRs("image")
%>

<table align="center" border="0" cellspacing="10" cellpadding="0">
<tr>
    <td class="PageTurner" colspan="5"><%if cint(varCurPage) > 1 then
                        %>                        
                              <a href="index.asp?page=<%=prepage%>&showtype=<%=showtype%>"><img src="../resources/images/interactive/prevena.gif" width="15" height="14" border="0" align="absmiddle"></a>
                              <%
                        else
                        %>
                              <img src="../resources/images/interactive/prevdis.gif" width="15" height="14" align="absmiddle">
                              <%
                        end if
                        %>
                          Page <%=varCurPage%> of <%If maxpages < 1 Then%>1<%else%><%=maxpages%><%end if%>
                          <%
                        if not cint(varCurPage) < cint(maxpages) then
                        %>
                          <img src="../resources/images/interactive/nextdis.gif" width="15" height="14" align="absmiddle">
                          <%
                        else
                        %>
                          <a href="index.asp?page=<%=nexpage%>&showtype=<%=showtype%>"><img src="../resources/images/interactive/nextena.gif" width="15" height="14" border="0" align="absmiddle"></a>
                          <%
                        end if%></td>
      </tr>
</table>




I HAVE CHANGED THIS TO BECOME THE FOLLOWING;-


<%
viewRange = cint(Request.Form("CID")) <----- I am passing a value to this from a previous page.
%>

Function owPreserve(owVariable,owDefault)
      owTemp = Request.QueryString(owVariable)
            'If the querystring contains any data it is counted as a variable change, if not the old variable is taken from the session or the default assigned
            If Len(owTemp) = 0 Then
                  If Len(Session("user_"&owVariable)) > 0 Then
                        owTemp = Session("user_"&owVariable)
                  Else
                        owTemp = owDefault
                  End If
            End If
      Session("user_"&owVariable) = owTemp
      owPreserve = owTemp
End Function

'viewRange = owPreserve("range",1)<------ commented out as causes the same records to be displayed all the time
varCurPage = owPreserve("page",1)
%>



<%
globalPageSize = 5
rsQuery.cursorlocation=3
rsQuery.cachesize=5

If viewRange = 0 Then
   Sql = "SELECT * FROM [product]"
Else
If PageAction = "results" Then
      'Builds the magical search sql query
Else      
      Sql = "SELECT * FROM [product] WHERE [range]="&viewRange&" AND [active]"
End If
End If
rsQuery.Open Sql, Con

If Not rsQuery.Eof Then
      rsQuery.MoveFirst
       rsQuery.PageSize = globalPageSize      

      maxpages = cint(rsQuery.pagecount)
      
      If cint(varCurPage) > maxpages Then
            varCurPage = 1
      End If
      
      rsQuery.AbsolutePage = varCurPage
      nexpage = varCurPage + 1
      prepage = varCurPage - 1
      Else
            varCurPage = 1
      End If

Do While Not rsQuery.Eof And Not curRecord = rsQuery.PageSize

tId = rsQuery("id")
tTitle = rsQuery("title")
tFeatures =

 rsQuery("features")
tImage = rsQuery("image")
%>

<%
      rsQuery.MoveNext
      curRecord = curRecord + 1
Loop
rsQuery.Close
%>
<table align="center" border="0" cellspacing="10" cellpadding="0">
<tr>
    <td class="PageTurner" colspan="5"><%if cint(varCurPage) > 1 then
                        %>                        
                              <a href="products.asp?page=<%=prepage%>&showtype=<%=showtype%>"><img src="../resources/images/interactive/prevena.gif" width="15" height="14" border="0" align="absmiddle"></a>
                              <%
                        else
                        %>
                              <img src="../resources/images/interactive/prevdis.gif" width="15" height="14" align="absmiddle">
                              <%
                        end if
                        %>
                          Page <%=varCurPage%> of <%If maxpages < 1 Then%>1<%else%><%=maxpages%><%end if%>
                          <%
                        if not cint(varCurPage) < cint(maxpages) then
                        %>
                          <img src="../resources/images/interactive/nextdis.gif" width="15" height="14" align="absmiddle">
                          <%
                        else
                        %>
                          <a href="products.asp?page=<%=nexpage%>&showtype=<%=showtype%>"><img src="../resources/images/interactive/nextena.gif" width="15" height="14" border="0" align="absmiddle"></a>
                          <%
                        end if%></td>
      </tr>
</table>



Thank you

 
0
claracruz
Asked:
claracruz
  • 6
  • 5
1 Solution
 
muzzy2003Commented:
Change:

viewRange = cint(Request.Form("CID")) <----- I am passing a value to this from a previous page.

to

viewRange = cint(Request("CID")) <----- I am passing a value to this from a previous page.

and then change:

                          <a href="products.asp?page=<%=prepage%>&showtype=<%=showtype%>"><img src="../resources/images/interactive/prevena.gif" width="15" height="14" border="0" align="absmiddle"></a>

and similar links to:

                          <a href="products.asp?page=<%=prepage%>&showtype=<%=showtype%>&CID=<%=viewRange>"><img src="../resources/images/interactive/prevena.gif" width="15" height="14" border="0" align="absmiddle"></a>
0
 
muzzy2003Commented:
Basically, the viewRange was passed in the QueryString originally, but you have changed this to post from a form. When you then navigate between the pages, passing data by QueryString, you lose this value. I have put it in, and allowed it to be resolved either from the Form or the QueryString.
0
 
claracruzAuthor Commented:
hello, thanks for that, but now i et the following error;-

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/shop-gs/products.asp, line 62

rsQuery.AbsolutePage = varCurPage<-------Line 62.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
muzzy2003Commented:
Try rsQuery.AbsolutePage = CInt(varCurPage)

Any better?
0
 
claracruzAuthor Commented:
still getting

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/shop-gs/products.asp, line 62
0
 
muzzy2003Commented:
Do you get this error when you first go to the page, or when you click on one of the page links?
0
 
claracruzAuthor Commented:
when i go to the first page
0
 
muzzy2003Commented:
That's before you hit the code I've changed then. Are you sure you're using the right URL? Has your session timed out?
0
 
claracruzAuthor Commented:
no it hasn't..
0
 
muzzy2003Commented:
Just a thought. You give the top of your page as:

<%
viewRange = cint(Request.Form("CID")) <----- I am passing a value to this from a previous page.
%>

Function owPreserve(owVariable,owDefault)
     owTemp

Is this correct? I don't think the %> should be in there, and perhaps it isn't, but I'm just trying to eliminate everything I can.
0
 
claracruzAuthor Commented:
i have changed the entire code to the so now works fine!!!! but thanks for all the help
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now