How can I make WebBrowser to navigate 1st site and then 2nd site?

I tried next C# code.

webBrowser1.Navigate("www.yahoo.com");

webBrowser1.Navigate("www.google.com");

I want to makewebBrowser1 (WebBrowser control) to load Yahoo web page fully (display full Yahoo web page), and then load Google web page.

But, with the code above, WebBrowser control displays Google web page only.

So, I tried following C# code.

webBrowser1.Navigate("www.yahoo.com");

while (webBrowser1.IsBusy) { }

webBrowser1.Navigate("www.google.com");

But, I failed.

Still, WebBrowser control displays Google web page only.

I tried bellowing code.

But, I failed.

webBrowser1.Navigate("www.yahoo.com");

while (webBrowser1.ReadyState == WebBrowserReadyState.Loading) { }

webBrowser1.Navigate("www.google.com");

I tried another C# code bellow.

But, I failed again.

webBrowser1.Navigate("www.yahoo.com");

while (webBrowser1.ReadyState != WebBrowserReadyState.Complete) { }

webBrowser1.Navigate("www.google.com");

What should I do to make WebBrowser.Navigate() loads 1st web page fully, and then loads 2nd web page?

[3612 byte] By [b2sing4u] at [2007-12-22]
# 1
try wrtiing the code to browse the google page on the DownloadComplete event of the browser control.
SaiTheodore at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
Hanging your form for the sheer purpose of waiting on a web browser is

bad practice in coding. Instead, I suggest creating a string collection

in your form, and using it as a queue. You could set the URL to

about:blank, add all the next URLs you want to the queue, then set up a

Navigated event. In the Navigated event, you could add a check to see

if there are any strings left in the queue, and if so, navigate to the

first one and remove it. As a bonus, this method lets you use more than

two URLs, and doesn't lag your application at all

ShawnZ at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3

It may be a bad practice, but you may try the following (which works fine for me):

while (webBrowser1.IsBusy)

{

Debug.WriteLine(webBrowser1.ReadyState);

Application.DoEvents();

}

... without the "DoEvents()" (I took from VB ), IsBusy won't change and the loop will be infinite

OldBrazil at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
Use a textbox (textbox1) to store your navigated address.

use bool to verify that this action has been performed:

//set to false on Form_Load or in Main Method
bool yahooCheck = false;
axwebbrowser1.Navigate("www.yahoo.com")

axwebbrowser1_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
//Fills the textbox with full URL loaded in browser
textbox1.Text = axwebbrowser1.LocationURL;

//check to see if yahoo.com
if(textbox1.Text == "http:\\www.yahoo.com")
{
//check to see if yahoo has been loaded before or not
if(yahooCheck != true)
{
//set yahooCheck to true to make sure this isn't checked
//every time Yahoo is navigated
yahooCheck = true;

//Navigate to Google
axwebbrowser1.Navigate("www.google.com");
googleCheck = true;
}
}
}

This was all off the top of my head. I haven't tested this or anything. But the logic made sense to me. The above code SHOULD navigate to yahoo, check to see if yahoo has been navigated before, if it hasn't it will load google right after yahoo has completely loaded.
TexasHammer at 2008-1-25 > top of Msdn Tech,Windows Forms,Windows Forms General...