Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8502405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:28:34+00:00 2026-06-11T01:28:34+00:00

i got a bit of a problem using the WebBrowser DocumentCompleted event. i have

  • 0

i got a bit of a problem using the WebBrowser DocumentCompleted event.
i have this code:

int timesToRun = 20;
private void Time_Tick(object sender, EventArgs e)
{
    if (timesToRun >= siteList.SiteLists.Count)
    {
        timesToRun = 0;
        webBrowser1.DocumentCompleted -= this.webBrowser1_DocumentCompleted;
        Console.WriteLine("timer is done");
        timer.Stop();
    }
        timer.Enabled = false;
        Console.WriteLine("timer is now disabled");
        Console.WriteLine(timesToRun);
        string currentSite = siteList.GetSiteFromIndex(timesToRun);
        webBrowser1.Navigate(currentSite);
}

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    WebBrowser wb = (WebBrowser)sender;
    if (e.Url.AbsolutePath != wb.Url.AbsolutePath) //somtimes dosn't return true
    {
        Console.WriteLine(wb.Url);
        forumAction.FillOutFormIn(wb.Document);
        timesToRun++;
        Console.WriteLine("timer is now enabled");
        timer.Enabled = true;
    }  
}

my problem that the if statment is true only somtimes. im not sure what more can i check to be sure the browswer is ready to use.

what else can i check?
or should i take a diffrent approch to this problem?

i got this if statment from a diffrent question here in stackOverFlow becuse i hed a problem that the event was fired more the onces (becuse iframe’s and stuff).

(sorry for my english)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:28:35+00:00Added an answer on June 11, 2026 at 1:28 am

    I think the problem is that the url of the browser can differ from the url of a nested IFrame, so when you call

    e.Url.AbsolutePath != wb.Url.AbsolutePath
    

    if the DocumentCompleted event is triggered by an IFrame, then the url in e.Url is the one of the IFrame while wb.Url is the url of the containing page in the webbrowser.

    If you need to check if the browser is ready to use you might have to wait a long time. You can loop through Frames property of (WB1.Document.Window.Frames) to see if the loading is completed.

    You could use external libraries like watin, it has a good check on document completion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
Using FlashDevelop, I've got a bit of code to detect keyboard events. The problem
I'm using progressbar in c# but I got a bit of a problem I'm
I got this html code from a book that i'm using to learn jquery
I've got a bit of a problem, I'm using a backgroundworker to do a
I've got a bit of a problem with making my data loading and filtering
I've got a bit of a problem. Essentially, I need to store a large
I've got this bit of JQUERY: <script> function initNav() { $('.nav tr table td
I've got a bit of Mac code that needs to store, access and update
I've got a bit of a problem. I'm currently working on converting an old

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.