I have a silverlight 3 application. When an unexpected exception occurs the error childWindow pops up. I Want to know what code should i write behind the "OK" button so that the application restarts over when the user clicks it.
thanks.
A quick and simple fix would be to just reload the page that the application is hosted on; you can use the HtmlWindow.Navigate method to accomplish this. If you don't want to reload the whole page, you could stick the application in an <iframe> and just reload that.
Related
I have an ASP.NET 4.5 web form running C# code behind on a server. A specific form often takes some time to finish while it updates and changes various database records. However, if the user closes the tab or tries to reopen the web form, it will try to check the users status in the database and fail when those later change due to the first running process.
The need is to track this specific instance of the process and user, and if it is still running, prevent the page from loading fully or redirect. I was hoping to find and store some user and process information on a cookie and then simply check for this each time on page_load. I was not able to find these variables/properties.
Am I going about this the right way, and if so, how can I accomplish this?
Thanks!
I was not able to find the exact solution I was looking for. At the moment, I cannot see any way to find a server side identification id of the process.
Instead, I referenced How to tell if a page unload in ASP is a PostBack and made it so that the page would warn when being unloaded before the confirmation screen is shown. As long as the form opens to the same named tab, the user would be given the warning screen and given a confirmation before they could close or reload a new web form instance.
I have a C# application which uses a System.Windows.Forms.WebBrowser.
The problem is: i'd like the user to navigate smoothly in my application, without prompts, without javascript windows popping up, without security prompts. Even if this requires some contents to be unavailable.
I just want to have one window (always one window, if a receive a new window event, i redirect it to the single window).
How can i do this?
I tried to use this.browser.ScriptErrorsSuppressed = true but i doesnt seem to work.
For example, if i test it on a browser page which performs text validation, i still receive a popup window saying that my text is invalid.
Thank you!
I've found a solution somewhere else, since it wasn't available here.
Here it is: http://www.codeproject.com/Articles/31163/Suppressing-Hosted-WebBrowser-Control-Dialogs
Basically, you have to hook the WM_INITDIALOG message.
It works wonders here.
I read a lot about application states, tombstoning and recommended practises but I am still confused
Here is my scenario
User launches app through application icon.
User then moves to next page.
User Click on Windows button.
User launches app again using application icon
What should happen here?
My second page should be displayed? because user didn't quit the app through back button
Main page should be displayed? because user launched it through app list which means new instance
MSDN says
Ensure that when your application is launched by the user from Start
or the installed applications list, the user is taken to a consistent
launch experience. It should be evident to the user that they are
experiencing a new application instance.
Does this mean that I should launch the main page again not second page?
If yes, should my app state only be restored(to second page) when user comes to my app through back button and Application_Activated event is fired?
You should start new instance of application.
I believe this is also part of certification process.
And the whole thing would get quite complicated, because only way to ensure, that application is onpened on same page, with same data, is to save whole state into isolated storage.
Unless you're doing some crazy custom stuff, this should be handled for you as page navigation is supported by the deactivation process.
If the user backs into your application, the last page they were on will be restored and PhoneApplicationService.Activated will be raised (ActivatedEventArgs.IsApplicationInstancePreserved will be true if you don't need to unpersist your state).
If the user accesses your application from start, the application's default page will be loaded and PhoneApplicationService.Launching will be raised.
The only thing I would show first one time only is the help or options screen so a new user can get to know the app.
From that time on, when the app is started it should start with the key/main page that the user wants to use.
Is it possible to invoke a back button press from code?
I want to simulate a physical back button press from the code behind for a page.
NavigationService.GoBack() will do just that.
You can't simulate a physical back button press. What I mean is you won't be able to navigate back from the first page, i.e. exit the application. Currently the only way for a WP7 Silverlight application to exit is to throw an exception. That said, if you just want to navigate back to another page in your app NavigationService.GoBack() will do the trick as keyboardP said.
By the way, why do you need to simulate a back button press? If you want to exit the app here's a nice article by Peter Torr explaining the various ways a WP7 app can exit. He also analyses scenarios that need exit functionality and talks about what can be done instead. In general, if you have some page with an ok/cancel buttons and you want the cancel to go back or exit, you can just remove it and let the user press the back button.
i am facing a problem with Getting a pop up message through pop up window in a stand alone application using c sharp.please help us ,thanks in advance.
I want to pop up a message to user to perform task at particular time .then i need to send the message to user through pop up window thats my requirement.
i am writing console application programs.
Regards,
M.Channabasappa
If you have console project - the best user message would, of course, console message. But If you still want to send pop up message to user just add reference to System.Windows.Forms assembly to your project and call message box:
System.Windows.Forms.MessageBox.Show("Hello! Im console app");
In WinForms, you need Form.ShowDialog(). In WPF, it's Window.ShowDialog().
To achieve a modal popup on a website is more tricky. Only IE really supports modal popups, and they don't "feel" nice to use. You can use bits of jQuery UI to get what looks like a popup but is in fact a div layered over the top of the whole page, inside the browser window.
HTH.
Anton's answer is correct, but in my case (Visual Studio 2010, Win7), I had to add System.Windows.Forms to my project as a reference to get it to work.
To do so, right click on your project in Solution Explorer > Add Reference > .NET tab > System.Windows.Forms > OK
Once I did this, I was able to add a MessageBox to a console application, which while it seems a bit counter intuitive was a good solution for this particular problem.