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 9325047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:44:57+00:00 2026-06-19T04:44:57+00:00

I have a simple C # application that contains buttons and a web browser,

  • 0

I have a simple C # application that contains buttons and a web browser, each button execute a request and displays the result of the request on the web browser. And I use the results of a request in the next button.

private void button1_Click(object sender, EventArgs e)
        {
webBrowser1.Navigate("http://www.test.com");
        }

private void button2_Click(object sender, EventArgs e)
        {
            if (webBrowser1.Document.GetElementById("tesxtbox1") != null)
            {
            HtmlElement txt1 = webBrowser1.Document.GetElementById("tesxtbox1");
            txt1.SetAttribute("value", "test");
            webBrowser1.Document.Forms[0].InvokeMember("submit");
            }
        }

my question is to find method or way to perform the two buttons with a single click, but the second button, do not execute until the web browser is loaded.
in my first solution, I added in the first button :

webBrowser1.DocumentCompleted + = new WebBrowserDocumentCompletedEventHandler (Button2_Click);

but the second button excuted several times, so I added in the last line of the button 2:

webBrowser1.DocumentCompleted - = new WebBrowserDocumentCompletedEventHandler (Button2_Click);

it works, but in the console I find that Button 2 is execute twice

Thanks in advance!

  • 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-19T04:44:58+00:00Added an answer on June 19, 2026 at 4:44 am

    You’re approaching this issue the wrong way. First you are not looking for a way to click two buttons. You are looking for a way to click one button and execute an operation if a condition is met.

    Basically you just need to call button2.PerformClick() in your WebBrowser DocumentCompleted method. If however you want to ensure that button1 was clicked, you can set a bool in button1 Click method and reset it in the button2 Click method.

    If you need to perform more than one button click in your document complete method after the first button click, you can add them to your DocumentCompleted method like this:

    First subscribe normally.

    webBrowser1.DocumentCompleted += Document_Completed;
    

    Normally you can generate the method stub by pressing TAB after subscribing to the event. The method could be as follows:

    private void Document_Completed(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
         //here you add the other buttons that must be clicked when document complete
         button1.PerformClick(); button2.PerformClick();//etc
         //you could even iterate all over the buttons on the form and click each of them if it meets a certain condtition.
    }
    

    I hope that answers your question 🙂

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

Sidebar

Related Questions

I have a simple C # application that contains buttons and a web browser,
I have a simple application that contains one button to be clicked in order
I have created an Ajax enabled WCF web service that contains this simple method:
I have an application that contains a main Activity, which has a very simple
I have a simple application that loads an unmanaged dll and passes a few
I have a simple c++ application that generates reports on the back end of
I have a simple WPF application that uses ClickOnce to handle installing. Within this
I have a simple iPhone application that is very similar to the Page Control
I have a simple Android application that uses a JAR I have built. When
I have a simple test application (C# console application) that does an HTTP GET

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.