From: - Electronic.HR - on
I have very strange and stupid problem with .NEt's webBrowser control...

If I do this:
----------------------------------
private void btnGoogle_click(object sender, EventArgs e)

{

webBrowser1.Navigate(http://www.google.com);

}
----------------------------------

and after that try this:

-----------------------------------

string html;

html = webBrowser1.DocumentText.ToString();

------------------------------------

I get error: "The system cannot find the file specified. (Exception from
HRESULT: 0x80070002)"


BUT


If I open Google (or any other page), and if I then click any link in
webBrowser, and after that try to get html content, all works fine...



Is there any way to get HTML content while navigating automaticly (with my
buttons)..

Hope I was clear :)

Thanks in advance.

Electronic.HR


From: Nicholas Paldino [.NET/C# MVP] on
The content is fetched in the web browser asynchronously. You should
wait until the downloading is done before you try and access the
DocumentText property. You can do this by subscribing to the
DocumentCompleted event and then getting the text from the document from
there.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp(a)spam.guard.caspershouse.com

"- Electronic.HR -" <electronic.hr(a)gmail.com> wrote in message
news:f44g54$mub$1(a)news1.carnet.hr...
>I have very strange and stupid problem with .NEt's webBrowser control...
>
> If I do this:
> ----------------------------------
> private void btnGoogle_click(object sender, EventArgs e)
>
> {
>
> webBrowser1.Navigate(http://www.google.com);
>
> }
> ----------------------------------
>
> and after that try this:
>
> -----------------------------------
>
> string html;
>
> html = webBrowser1.DocumentText.ToString();
>
> ------------------------------------
>
> I get error: "The system cannot find the file specified. (Exception from
> HRESULT: 0x80070002)"
>
>
> BUT
>
>
> If I open Google (or any other page), and if I then click any link in
> webBrowser, and after that try to get html content, all works fine...
>
>
>
> Is there any way to get HTML content while navigating automaticly (with my
> buttons)..
>
> Hope I was clear :)
>
> Thanks in advance.
>
> Electronic.HR
>

From: - Electronic.HR - on
Hm...good idea.. but it doesn't work either...
I done this
<CODE>
private void webBrowser1_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{

string html;

MessageBox.Show("Document Completed");
html = webBrowser1.DocumentText.ToString();
MessageBox.Show(html);

}
</CODE>


first message box appears, but second one doesn't!
(In this case nothing happens. In this case there's no Exception showing,
but second message box doesn't appear) ?!?


From: Nicholas Paldino [.NET/C# MVP] on
Well, by default, exceptions thrown by event handlers on controls are
swallowed. You will have to wrap in a try/catch block to figure out what
the exception is (you can look at it in the debugger too).

--
- Nicholas Paldino [.NET/C# MVP]
- mvp(a)spam.guard.caspershouse.com

"- Electronic.HR -" <electronic.hr(a)gmail.com> wrote in message
news:f44i9r$ona$1(a)news1.carnet.hr...
> Hm...good idea.. but it doesn't work either...
> I done this
> <CODE>
> private void webBrowser1_DocumentCompleted(object sender,
> WebBrowserDocumentCompletedEventArgs e)
> {
>
> string html;
>
> MessageBox.Show("Document Completed");
> html = webBrowser1.DocumentText.ToString();
> MessageBox.Show(html);
>
> }
> </CODE>
>
>
> first message box appears, but second one doesn't!
> (In this case nothing happens. In this case there's no Exception showing,
> but second message box doesn't appear) ?!?
>

From: - Electronic.HR - on
When I click on a link in webBrowser, only then DocumentText fills with
content...

What's difference between:
- clicking on a link in webBrowser and
- calling webBrowser1.Navigate(...);

?