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

  • SEARCH
  • Home
  • 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 6760973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:07:46+00:00 2026-05-26T14:07:46+00:00

I need to click an html button and navigate to another page. After click

  • 0

I need to click an html button and navigate to another page. After click I need to wait for page loading, and go to the new page only when the old page loaded.

Here is the code, that click a button:

element = webBrowser1.Document.GetElementById("LoginButton");
element.InvokeMember("click");

webBrowser has got a IsBusy property, but it don`t works after button click:

element = webBrowser1.Document.GetElementById("LoginButton");
element.InvokeMember("click");
if(webBrowser1.IsBusy)
{
     MessageBox.Show("Busy"); // Nothing happens, but page is not full loaded.
}

If I add System.Threading.Thread.Sleep(1000) the page loads and I can go to next page, but page loading time on other computers can be more.

What can I do to load another page only after the previous page has loaded?

P.S: I am from Russia, so sorry for bad 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-05-26T14:07:46+00:00Added an answer on May 26, 2026 at 2:07 pm

    If your webpage has any javascript blocks, you won’t be able to solve the problem using the WebBrowser control itself. You should wait for a document.ready event using javascript code and let know your C# program about it.

    Previously, I made a javascript block that provides the webpage state. It looks like this:

    var isBusy = true;
    function getIsScriptBusy () {
       return isBusy;
    }
    // when loading is complete:
    // isBusy = false;
    // document.ready event, for example
    

    and a C# code that waits for it to return true:

    void WaitForCallback(int timeout) {
        Stopwatch w = new Stopwatch();
        w.Start();
        Wait(delegate() {
            return (string)Document.InvokeScript("getIsScriptBusy") != "false"
                && (w.ElapsedMilliseconds < timeout || Debugger.IsAttached);
        });
        if(w.ElapsedMilliseconds >= timeout && !Debugger.IsAttached)
            throw new Exception("Operation timed out.");
    }
    void Wait(WaitDelegate waitCondition) {
        int bRet;
        MSG msg = new MSG();
        while(waitCondition() && (bRet = GetMessage(ref msg, new HandleRef(null, IntPtr.Zero), 0, 0)) != 0) {
            if(bRet == -1) {
                // handle the error and possibly exit
            } else {
                TranslateMessage(ref msg);
                DispatchMessage(ref msg);
            }
            Thread.Sleep(0);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need my HTML page to be steady whenever I click a link or
Need to programmatically click an html button from a login event (code behind? the
I have a JavaScript function for a HTML button click event in aspx page
In my PyGTK app, on button click I need to: Fetch some html (can
I've a page on html. When i click on a submit button i call
I have a hidden button on a form that I need to click in
I need a function that a user can just click a flash app button
I have a single HTML page where I need to have three jqm pages
I've got a web page where I need a user to click the save
I need to replace a button on my web page with a hyperlink. I

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.