Monday, March 1, 2010

Programmer - Why is WebBrowser_DocumentCompleted() firing twice?

Programmer Question

Well, I'm using a simple webbrowser control to browse to a page, so I need to change the Text of the form while doing so. I'm using -



private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
this.Text += " - " + webBrowser1.Document.Domain;
}


but using a breakpoint, i noticed that, this event is firing twice. I even tried _Navigated() event. it also fired twice. Resulting the title to "Webber - google.co.in - google.co.in" ..



I also noticed that this event fired several times while loading msn.com.. I'm trying to change the text of the form only when the page has finished loading totally..



Any remedy?



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails