Ragesh Puthiyedath Raju
Ragesh Puthiyedath Raju

Reputation: 3939

WebBrowserReadyState is always shows " Interactive " in DocumentCompleted event

I have working on windows application in the VS 2010 C#. I have used a Web Browser in my project. My application woks fine till the last week, but i found some problem in that Document Completed event.

Please see my code below.

  private void HomeBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        if (HomeBrowser.ReadyState == WebBrowserReadyState.Complete)
        {
            if (HomeBrowser.Document != null)
            {
                ...............................

please see the first if condition in my code. if this condition is not satisfied

rest of the code is not working. I don't know what happened.

Any Idea. Would you please help me as soon as possible.

Upvotes: 0

Views: 3341

Answers (1)

Damian Lascarez
Damian Lascarez

Reputation: 46

In this case you don't need validate if the ReadyState is completed because the document completed event will execute when the browser has finished.

private void Form1_Load(object sender, EventArgs e)
    {
        this.webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted);
        this.webBrowser1.Navigate(new Uri("http://www.amazon.com"));
    }
    private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        if (this.webBrowser1.Document != null)
        {
            //Your code ...                
        }
    }

Upvotes: 2

Related Questions