HI, I am new to webBrowser tool in C#.

If i use this code to navigate, and get the page source.

Webbrowser1.Navigate("http://www.google.com");
HtmlElement he = Webbrowser1.Document.Body;
string pagesource = he.InnerHtml;

But i am not getting the webbrowser fully loaded and i am not getting the full pagecontent.

Help me?

you need to wait before the browser is completely navigated..

use something like this

WebBrowser wb = new WebBrowser();
                HtmlDocument doc = null ;
                wb.Navigate("WWW.GOOGLE.COM");
                do
                {
                    Application.DoEvents();
                } while (wb.ReadyState != WebBrowserReadyState.Complete);

'Here do your coding

Edited 5 Years Ago by sandeepparekh9: n/a

you need to wait before the browser is completely navigated..

use something like this

WebBrowser wb = new WebBrowser();
                HtmlDocument doc = null ;
                wb.Navigate("WWW.GOOGLE.COM");
                do
                {
                    Application.DoEvents();
                } while (wb.ReadyState != WebBrowserReadyState.Complete);

'Here do your coding

I tried this but it didn't help me..

it sure worked for me..

here is the form load coding

private void Form1_Load(object sender, EventArgs e)
        {
            WebBrowser wb = new WebBrowser();
            wb.Navigate("www.google.com");
            do
            {
                Application.DoEvents();
            } while (wb.ReadyState != WebBrowserReadyState.Complete);

            string str = wb.Document.Body.InnerHtml;
        }
This article has been dead for over six months. Start a new discussion instead.