Sorry, I attempted to tab in the previous post and accidentally posted
prematurely.
I am trying to use the WebBrowser control from Visual Studio 2005 to load a
web page and display its HTML content in a text box on a Form of a Windows
Application. I have a button on the Form that invokes the following code
when clicked:
webBrowser1.Url = new Uri("http://www.microsoft.com");
textBox1.Text = webBrowser1.DocumentText;
However, this does not work because the page does not actually load until
the button click method has returned. To actually load and display the page,
I have to click the button twice and do this:
if (toggle == 0)
{
webBrowser1.Url = new Uri("http://www.microsoft.com");
toggle = 1;
}
else
{
textBox1.Text = webBrowser1.DocumentText;
toggle = 0;
}
I want to capture the page contents with a single button click, but I
suspect I will have to do something in a thread or use invoke or something.
Can someone give me an example of how to do this?
Thanks in advance,
Don