Webbrowser: sequencing activites when no DocumentCompleted is fired by...

sabato 14 aprile 2012 - 23.45
Tag Elenco Tags  C#  |  .NET 3.5  |  Javascript  |  HTML 4.01

InsettoScoppiettato Profilo | Junior Member

Given this method to work on a HTML page in a webbrowser:

Il codice sorgente non è stato renderizzato qui
perchè non c'è sufficiente spazio.
Clicca qui per visualizzarlo in una nuova finestra

I need to understand why this code runs like a charm when the messagebox is displayed and does not when it is commented out. My doubts can be resumend in these questions:

1) how is the flow of the code when the message box is part of the program and when it is not? I mean is the code blocked up to the user presses ok?

2) the phase I indicated above with number 3 fires some javascript in the page that does not issue a Navigating event (therefore no DocumentCompleted) but gives access to some hidden HTML not reachable without clicking on a A tag. In practice it just changes the InnerHtml of a tag, creating a FORM in it.

3) I tried to implement several solutions for phase 4, a Message box as indicated here up, a ThreadSleep(), a SpinWait() and even a for loop messing everything up, but all those solutions seem not to let the Webbrowser proceeding in visualizing the form on screen. Only the message box brings it up to screen, even if the user is very fast in pressing OK and closing it.

4) I need to find a solution that does not involve external (user) input (such the Messagebox to be closed) in order to wait for the form to appear completerly loaded on the screen, but no events come to help.

Some more data to evaluate the case: - the code I wrote is good for the aim, I tried to split it into 3 buttons to manage the timing by hand and it works fine. - the document completed cannot be used for switching between code splits, as there are around 300 pages automated and each page can have 10-15 methods to automate them, it's impossible to manage a single eventhandler for all of them, without builind up a neverending Switch struct. I would try t avoid it if possible. - i've found some interesting issues of other users like the following but without solution for my case:

InvalidCastException with WebBrowser.IsBusy or ReadyState (VB .NET)

Detect when AJAX changes HTML in a DIV in WebBrowser


Could somebody give me a hand.

Sorry it is my first thread, hope I've been clear. Tks

Alessandro Parma
Programmazione multipla scoposta con prognosi ancora da definirsi
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2017
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5