How to remember page in table when navigating back - google-app-maker

I have a table in page A, and can by clicking on entries in the table jump on a new page B for detailed editing.
Right now, when I navigate back to the table on page A, the table reloads on page 1. This can be painful when editing a number of entries in the middle of a large table.
I would like the UI to remember which page I was on. Is there a painless way of doing it ?
Update: I get the reload when navigate back through the browser back button OR the window.history.back() method.
Yes, I probably reload the datasource. For a reason, since I have some selectors on page A that fiddle with query filters), but I'll see if I can avoid the reload. I don't really know how to do it without remembering my previous state.

OK, so it turns out that I really don't need to reload the data source at attach. I just need to do it as I change the queryfilters in page A. Then however I also need to remember to change pageIndex back to 1, because somehow THAT is remembered.
Thanks for the help!

Related

ASP.Net Grid View return to page index

I know others have had a similar issue as me, but no one so far seems to have a solution to it. Basically, I have a simple GridView with a pager and I can get the page index from it (GridView1.PageIndex etc..). But how can I retain this when a user clicks on a hyperlink bound in the Gridview to another page, update some details, then come back to the page with the GridView. So they go to page 4, click the link, update details, then go back.
I can set the value in the session and get it form the page I go to, but on databound I am checking for it and trying to set it, but it just does not work. Is there a built-in function that Microsoft thought of?
Ok, so after sucking on some caffeine I discovered that I needed to set the new Page Number on PageIndexedChanged to a session variable (best option) and on DataBinding check the session and if it exists, get the value and apply it, otherwise set it to 0 (page 1) - works a treat, hope it helps someone else.

Keep history of old page

I am running some stored procedure and on the basis of that i am doing some calculation and then display their counts and their images on the basis of the data.
then I have each button where I am moving forward with that Detailed data.
Now If I want to come back on this page with the old data then what should I do?
I have been already tried history.back(-1) or history.back() etc.. It will take me back but not with data and only with the control.
I need to come back with the data.
Please help me out.
Thanks.
save it to Session.
and in the PageLoad - Reload it from the Session.
history.back() just tells the browser to navigate back to a previous page... the exact page the browser originally saw (i.e. it will not fetch it from the server again with possibly changed data).
It's better to navigate forward to the page when you want to see it again with updated values. Redisplay the page when you revisit it, this time with the appropriate data. As Royi suggests, you can save that data in the Session.
You could always load the detailed data into the current page with an AJAX call when you click your details button. This way you preserve the state of the original page.
When navigating "back" just unhide the div that contains the initial view of the data.

Maintaining State Within Pagination

I am currently working on a site for an auto dealer and ran into a bit of a snag when I started trying to ad pagination to the inventory page.
The inventory page has 5 search options type, make, year, model and trim. They are all drop downs and they are all populated by a live feed, changing the options autopostback the page and the inventory/nav are updated accordingly.
Everything was working great until I went to add pagination to the page. The pagination works fine for what it is, if there are more then 15 results it adds a numbered nav to the page that allows the user to jump pages.
4
The problem is when they do jump pages all of the search options revert to there original settings, and when the page loads its pulling in every car again instead of what the user searched for. I can't really figure out what the issues is, I expect the state is getting lost when the user clicks the link even though it is to the same page. I tried using sessions but it seems to have muddied it up, does anyone have any suggestions for a fix?
If you require the code I can link it, I warn you though it is a pretty large amount of code and I don't think you could find much in it, but who knows.
Try using a LinkButton control with an OnClick event. Do whatever you are doing when you test for the "page=4" querystring parameter in the OnClick event. You are losing state because the a regular html anchor tag causes the page to load as if it were the first time you visited and ViewState is blown away - Page.IsPostback is false.
If you don't want to use a sever side control, you could always pass the search parameters in the query string.
4
If you do it this way, please be sure to sanitize your inputs before you pass them back to the database.

Maintaing changes on the previous page

I have a page in asp.net by clicking on the grid in the page it takes me to the detail page,on this page i have a back button (not browser back) by clicking on the button it takes me again to the search page.
i want to see the page with changes which i have made before coming to the detail page,also i want to disable back button of browser.
i dont want to use session variable or viewstate variable.
is there any property for this scenario.
yours sincerely
Talha khan
You can't disable the browser back button. End of story. Sorry.
What changes are you making to the grid, where is it getting it's data from? You could use a cookie to store the previous pages' state if you don't want to use session or viewstate.
If the the amount of data you need to track is relatively small (in your case this would probably be a search query) you can use query string to pass the state to the detail page (which can be later passed back to the search page).
You can also use browser cookies to persist the state but I wouldn't do that (at least because they're not designed for this kind of interaction).
-- Pavel
There are several ways to solve this.
The first that comes to mind is to change the page to AJAX. AJAX would not force a page jump forward, hence there will be nowhere to go back to.
The second way is to have a check on the previouis page, for example set "Session("if_search_go_here") = Request.Url.PathAndQuery" and unset it at the right place. If this is set then the search page will just forward you to the detils page again.
probably more. :)

Need help in asp.net viewstate

Pls somebody help me with viewsate. Suppose i have created two forms. First form contains First name and Last name and one button called NEXT. And Second form contain two fields and two button like Back and Save. While i am entering some value in form1 pressing one NEXT button and redirecting to second page. There when i am pressing Back button from second page it should come to first page whichever data i filled should exists, but in my case its not showing only empty form i can see when i am pressing on back button.
For this i have used viewstate mechanism. in page directory i have set enableviewstate=true.
postbackurl in both the button. Pls somebody help me what is wrong with me.
Thanks,
Sumit
Viewstate won't carry information from one WebForm to another. It only carries information across postbacks on the same WebForm.
You want to use another method, like SessionState, to carry information from the first page to the second page. Otherwise, you could combine all your inputs on the same page and separate them into multiple steps using something like the ASP.NET Wizard control.
David Lively's suggestions of cookie or database solutions are good, too.
ViewState will help you ship data between views/postbacks of the same page, but isn't really going to help you when moving data between separate pages.
In your first page, populate a cookie or database with your form fields. Any form can then update the cookie, delete it, or what have you.
You can call a javascript function that is doing a "real" back. Maybe I am missing something but this is what I would do.
onClick="history.go(-1)"
When a page is called from some other page it is not a post back, it is viewed as if it is a first time call... When a page is called from the same page then it is termed as a post back... View state or in the sense control values are maintained only during post back, and gets reseted to form values during first time call...
This is the reason behind why you are not seeing the values of the controls.
As others suggested, try using session or cookies and the best option would be Wizard.

Resources