In my Silverlight app how can I determine if the Back button is pressed and to not logout, as it is currently doing. I may have a problem as the app is primarily a grid with drill down but at least if it could return to the start page, would be great.
I think the only way to trap that is with javascript. And the only thing you can do that way is to get an OK Cancel standard messagebox.
Or what you can do if you want to manage different pages with silvelight; create a Silverlight Navigation application (with the appropritate template).
Related
maybe it's quite easy question, but I haven't managed to find a solution. I'm using web browser only to display data, and don't want user to access shown webpage. I know that in win forms' webbrowser it's possible, but how can I achieve it using WPF control?
PS I don't want to lock browser action in the navigate event, as described here: How can I make a WPF WebBrowser read-only? , because this won't stop my user from running javascripts etc
PPS And I also don't want to disable js, because I want it to be used by webpages. What is more, I'm executing it from code, as long as navigating between sites
Add this to Windows_Loaded Event
webbrowser1.IsEnabled = false;
I am developing a winform app which is controlling a website. On click of a button in winform app i want to fill a form, click the submit button on the web page upon which a new page will open , on that page i have to click on a link.
How to achieve this. i have tried many things but did not got any proper solution
If you're looking for a web automation tool, use Watin. It allows you to automate via code the opening of a browser, the clicking of buttons, and the fillout of form fields. However, that is more of a testing library.
Honestly though, your choice of solution sounds odd. You're trying to get a client application to make requests through a web page, instead of directly requesting whatever resource yourself from the client application. It's hard to give you a direct solution without a good understanding of the problem space.
As stated by Microsoft, it's not possible to programatically navigate from the main page. I have a EULA page that I need to show if the user is using the app for the first time. My plan was to determine on the main page if the app has been used before. If not, I had planned to navigate to the EULA page, but this is not possible. How can I get around this navigation limitation?
The issue with a dedicated EULA page that is automatically pushed on the back stack is that the application won't quit when the user presses the Back key when in the EULA page.
You should instead use a Popup control that you show and hide when appropriate.
See Peter Torr's post on how to exit an application for more details and background.
It should be possible to navigate from the main page easily using:
if (!eulaAgreed)
NavigationService.Navigate(new Uri("/EULAPage.xaml", UriKind.Relative));
Probably best to put this code in OnNavigatedTo of your main page or even later in the page cycle using Dispatcher.BeginInvoke(...). Putting it before that (i.e. in the constructor or Loaded) may not work.
What do you think happens to the Navigation stack?
Would the users be able to access the EULA page again? maybe by clicking back from the MainPage ?
I'm trying to automate a web process where I need to click a button repeatedly. When my code "clicks" that button (an HtmlElement obtained from the WebBrowser control I have on my form) then it brings focus back to my application, more specifically the WebBrowser control. I wish to better automate this process so that the user can do other things while the process is going on, but that can't happen if the window is unminimizing itself because it's attaining focus.
The code associated with the clicking is:
HtmlElement button = Recruiter.Document.GetElementById("recruit_link");
button.InvokeMember("click");
I've also tried button.RaiseEvent("onclick") and am getting the exact same results, with focus problems and all.
I've also tried hiding the form, but when the InvokeMember/RaiseEvent method is called, whatever I was working on loses focus but since the form is not visible then the focus seems to go nowhere.
The only non-default thing about the webbrowser is it's URI being set to my page and ScriptErrorsSuppressed being set to True.
Why do You need to click this button? It's sending some form?
If yes, you can use WebClient and simulate sending form without graphic interface.
Basicly almost anything significant requires connection to website using Get Post or multipart/post so WebClient will be perfect. You can simply get the site wich is this button on and parse it to get what clicking it do. And then simulate your own action.
In IE7 or higher you can implement IProtectFocus on the webbrowser site and deny the focus change. You would be much better off if you use the raw ActiveX or its wrappers that support this kind of customization, e.g. csexwb. If you have to use the winform webbrowser control, you need to create your own webbrowser site.
Well, the title is pretty much the whole question. I'd like to be able to clear the WebBrowser controls history on every Navigate - to prevent my users from going back to a previous page. i already disabled the right click menu so they don't have access to the "Back" option, but they could still hit Backspace to go back in history. blocking the backspace key pres would cause problems when a user is legitimately using it to delete characters in web forms and such, so i figure just clearing out the history each time i navigate would completely solve the problem
EDIT: alternatively, if there is a way to detect if the Backspace key is currently pressed, i can add a check inside my handler on Navigating and cancel the event if the key is down. Too bad .NET 2.0 doesn't have the Keyboard class :(
It might be easier and more robust to use the Navigating event to cancel a page navigation you don't want to allow.