to show loading while navigating a web page using c# .net browser - c#

hiii
I am developing a window application in which I am showing a web page using c# .net browser. since my web page is quite heavy and its taking time to load . so i want to show loading image while navigating a web page .so tell me how should i do .

I assume that you are using the WebBrowser wrapper, is that correct?
You can use the ProgressChanged and/or Navigating + DocumentCompleted events.
As an asside:
Depending on the nature of your application you could pre-download parts of the page to improve the user’s pereption of the app’s responsiveness.

It may sound overly simple, but it might be the easiest solution to just add an image control with an animated bitmap to the form at runtime when the page starts loading. Once it's done, just hide the image again. This would also give you the flexability to display any messages you want and add effects/transitions to make it aesthetically pleasing.

Only since you asked so nicely.
You could just do this by monitoring both the navigating and the documentcompleted events of the webbrowser control. (Im sure you can fill in the blanks here).
Be sure when you use the documentcompleted event that you check the readystate :
theBrowser.ReadyState == WebBrowserReadyState.Complete
Otherwise the documentcompleted event will fire multiple times even before the entire page has loaded.

First create an image(give a name for it) and place it wherever you want it but make the Visibility to Collapsed.
Then in your browser_Navigating, add this code, ImageName.Visibility = Visibility.Visible;
and then in your browser_Navigated, add this code, ImageName.Visibility = Visibility.Collapsed;

Related

How to track action performed on web view content UWP

I have a WebView in UWP which is getting some html content (including javascript).
I need a way to track actions performed on the Webview content, for instance if the user has clicked a button I would like to know.
I know https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webview.scriptnotify
but for this to work javascript has to call window.external.notify().
But the problem is that I don't own this content and it doesn't make sense to ask the owners to change their handler to publish this window.external.notify().
So, is there any way I can track all the user actions without modifiying the content?
I don't think you can accomplish what you're wanting to do with the UWP web viewer.
One alternative to consider is CefSharp which has a WPF implementation of Chromium.
It gives you a lot of hooks and handlers to intercept requests and do a lot of custom work on JavaScript that you don't control. I used it to build a WPF based help system and it allowed me to intercept links to PDFs and videos so that I could display them in special viewers.

Windows Phone browser live html modification

I haven't looked into it very much but am struggling to find relevant information on the topic. I basically want to create a browser that applies a filter to a webpage by changing colors in a webpage. My guess is that I will have to change the html once loaded or something, would this work? Do I have other options?
PS. I don't just want to make every color darker, I would more like to invert the colors.
Edit:
If any you were wondering, I am talking about the XAML browser component that can be used in a Windows Phone application.
I think the simplest way to do that is to inject some Javascript into your page once it has loaded.
To do that, you need to set the IsScriptEnabled to true on your WebBrowser control and then subscribe to the Navigated event.
When that event occurs you can inject some JS codeby using the WebBrowser.InvokeScript method.
Here is an example of JS code that darken the page : JavaScript: Invert color on all elements of a page
If you are talking about in a PC internet browser, you can find an add-on to execute Javascript automatically, such as Greasemonkey for Firefox. If you are talking about Windows Phone's Internet Explorer, I don't really know what you could do there, as I don't think they allow add-ons.

Detect webBrowser document changes after DocumentCompleted has been fired

I am using a WebBrowser control. I edit some HTML inputs and click a button in the WebBrowser DocumentCompleted event handler. My problem is clicking the button I mentioned changes the content of the Document using AJAX, Knowing that I need to parse some information from the new changes. The question is: How can I detect when the document has finished loading the new content. Is there any sort of an event handler like DocumentChanged.
Thanks in advance.
I figured you'd be back about this. The extensibility object model has no great support for observing scripting execution. It isn't practical, scripting code can run completely asynchronous from the page state at unpredictable times. If there are no reliable DOM modifications made by the script that you can read back then you have no great options beyond just spinning your wheels for a couple of seconds to give it 'enough time'. Shouldn't be a problem given that you run this in a worker thread, just use a System.Windows.Forms.Timer who's Tick event calls Application.ExitThread to end the thread.
No way to do that, I'm sure - WebBrowser control is very simple and poor-functional
Do you control the HTML of the document you're displaying ? If so, after the ajax changes have completed you can use Javascript to call a C# method in your parent form window.external.MyPublicMethodName() instead. Your app needs to be running in Full Trust for this to work, and also to have set the browser ObjectForScripting object to the form itself e.g. this.webBrowser1.ObjectForScripting = this; in your Form_Load event.

Integrate Moneybookers into WPF applications

I would like to integrate moneybookers payment-gateway into a WPF-application. Accroding to the official gateway manual I need to redirect the user to the moneybookers payment-page and submit some fields posted within an html-form.
Has anyone an idea how I could solve this task?
Best regards!
Yes, all you need to do is:
Include a Frame control in your WPF application.
Include a .html file in your WPF application that contains a element with the appropriate data and some JavaScript to automatically post the form when the page is loaded.
When it is time for payment, have your display the Frame control and set its Url to the relative path of the .html file.
When the user is done paying you can give them a button to close the Frame yourself, or you can subscribe to the Navigated event on the Frame and when the payment processor causes them to navigate back to your fake HTML you can automatically close the Frame and use your own WPF UI to tell them "congratulations, thanks for paying".

ajax process control

Is there any builtin control in ajax to show process indicator. Like when i press copy button in my page one popup shuold come and show a small process animation gif.
is it possible in ajax using c#?
Some time ago I need to do this in my web site and I've found this page. Check this out and see if fits to your needs.
http://mattberseth.com/blog/
Cheers,

Categories

Resources