Storing previous page

I have a web app with multiple pages and I have added a Container to each of the pages and within the container I have a “Back” button. I want the user to be able to press the button and the previous page of the app to be displayed. So whenever the page changes I have a pLastPage = self.Page where pLastPage is a module property of type WebPage. When the user clicks the back button I issue a pLastPage.show but this produces an error that the object is nil. It is highly probable that I am using the totally wrong approach!!

You may have code that specifically opens the previous page and closes the current page in your button. If you need to bring back the data for the page, then you need to keep it stored in underlying classes/properties that you can retrieve and display anew when you reload the page, or you run methods to read again the data from the database or other data store.

We don’t know much about your application, I am assuming that from one page you go to one other page. If not, then you will need to maintain a list of visited pages and their order. Your back or forward buttons will use this list to know where to go next. The page open event may be the right place to place the code that updates the stack (list). Your list will need some way to maintain the currently open page, in order to branch to the right place if the same page was opened and closed multiple times at different times. The list would presumably be a session property.

Thanks Louis, I am confused by the object parts. Am I right to store the current page (before I leave it) in property of type WebPage ? If so then when I use that property on another page using the show it gives me a nil error. I am just not sure if I am using the write object type etc.