Question regarding state of pages while deactivation and activation of page,i save the datas for that particular page alone.when i go back to previous page,by pressing back button,I am getting previous page which does not have data in it.To load the data in the previous page i need to get the instance of previous page ,is there anyway to get the instance of previous pages in Phone Application stack.,Other thing,is that On backkey Press,handling onbackkey press,by navigating to the new instance of the previous phone application page(what will happen to old instance of the previous pages).how to handle these scenarios?
You have asked some questions recently on page state. When an app is deactivated and activated again Windows phone 7.5 saves the page state. All that you need to do is to carefully handle the Page_Loaded and OnNavigatedTo events upon activation.
And if you want to override the back stack OnBackKeyPress, you can do so and navigate to any other page instance. But you should ensure you removed the back stack entry. otherwise causes many problems.(but this is not recommended)
NavigationService.RemoveBackEntry();
Related
I have a contact addition form that can be navigated to from multiple screens in our application.
Once the form is submitted, I then take the user to a screen to view the contact that was added.
When the user then makes use of the back button it should take them back to the screen that they originated from.
This might be the Android back button or one that calls the RouterExtensions back function.
I have made use of the navigate extra replaceUrl when navigating away from the form to the view page.
I have also tried using the skipLocationChange extra when navigating to the form but this creates more issues.
I have created a simple playground page flow that creates not quite the same issue but does throw an error that I don't know what to do with either:
https://play.nativescript.org/?template=play-ng&id=BfVcGZ&v=2
In our app, by making use of the replaceUrl extra, the back button does take the user to the correct page.
However, there is a brief moment where they see the form again. This isn't an ideal user experience.
In the linked Playground I do get an error:
Cannot reattach ActivatedRouteSnapshot created from a different route.
This seems to tell me that replaceUrl is indeed removing the page from the route table.
However, the page isn't destroyed yet and so the app is trying to show a page that it shouldn't.
replaceUrl is not yet supported by Page Router Outlet, there is an open feature request, you might want to register your vote on the feature and follow up there for further updates.
I am coding for a basic windows phone app. First time when the application is getting launched, data is getting loaded properly in listbox. Now after clicking on any item in list box, I am navigating to another page. But when I press back button to come back to main page. a new set of similar data is getting appended to list box items. how do I check whether data was already loaded or not.
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
In my call back MainPage_Loaded I am binding my data.
You should see how navigation works in Windows Phone. When you go back, the Loaded event gets raised every tmie.
The constructor, however, gets called only when the page is created the first time. When you go back, you actually don't call the constructor again, the page is cached. So, in order to stop the data from loading again, you might want to try loading it in the constructor. That's the simplest way.
The other way includes some form of a bool flag which keeps track of that.
I have a few pages in an Application that require A-Synchronous calls to be made for about 2-3 minutes to get Synchronized, the user may navigate away from that page during Synchronization and can come back again after visiting multiple pages and the sync continues all the time he is on other pages as well, when I go to a page from sync-page and press the Back button everything works fine.. but when i go to a page and navigate back to sync-page from Application Bar a new Instance of the Page is created and the Sync is just like Re-started.
Now i know every thing is working fine since new instance of a page is created when i call NavigationService.Navigate() , but what should i do in this scenario ? How to get the old instance of a page if it is there ?
Thanks...
You can't get an "old" instance of a page and it's not guaranteed that a backwards navigation will reload the previous instance of the page, it may be a new instance of the same page, but restored to the same state (assuming you saved any).
If you are trying to provide backwards navigation from the application bar then a) you probably shouldn't because that's what the back button is for, and b) you should make sure you use NavigationService.GoBack() instead of NavigationService.Navigate() because Navigate will always launch a new instance of your page.
If the page you want to get to is not the previous page, then it sounds like you are trying to implement non-linear navigation for which there is a recipe on the App Hub.
By the sounds of your scenario, you should handle this long running process separately (away from the view) and then display it's progress or results in a view when the user navigates to the relevant page.
I am implementing a web application using ASP .Net and C#. One of the pages has a requirement that it always needs to be fetched from the server, rather than from the local browser cache. I have been able to achieve this.
We have a back button in the application, which simply invokes javascript:history.back() method. The problem is that when the back button is clicked to navigate to the page which is always to be reloaded from the server, the browser displays a "Web page expired message".
The intent here is to force the browser to reload the page rather than display the web page expired message.
Any help would be highly appreciated. Thanks a ton in advance.
You will probably need to change the implementation to make the browser load the URL explicitly:
window.location.href = 'http://....';
instead of invoking the back button, since the intention of the back button is to get the last page from the cache.
(If browsers would not act that way, they would re-send your form data multiple times when using the back button during a registration process or similar.)
You mean you want to control browser behaviour, which is not possible. I doubt you can solve it that way. You could set the expiration time to a small value (1 minute perhaps?) so that the page is still valid if one navigates back quickly.
I have a web application (Java, Websphere, JSP) which allows co-workers to register visitors to various company exhibitions. A user object is stored in the session which records the currently selected exhibition and this is used when entering the details of new visitors.
One user has decided to open a second browser window which seems to share the same session. The user browses to an other exhibition in the second window. This changes the state of the currently selected exhibition. Back in the first window a menu item is clicked: 'List visitors'. The resulting list is a list of visitors to the exhibition selected in the second window.
I know that I could add the exhibition id to every form on every page but my actual scenario is more complicated that the one I have described.
What is your stategy for dealing with this kind of problem?
My first guess would be you can avoid the problem by keeping (or perhaps only identifying) view state in the URL and not the session.