Hey

So i got a Webbrowse (wb_MainBrowser) and a button.


for the webbrowser i got a code that looks like this:

private void wb_MainBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (wb_MainBrowser.Url.ToString() == "http://www.google.dk/")
            {
                MessageBox.Show("HEY");
            }
        }

and i got a button that goes

private void btn_Start_Click(object sender, EventArgs e)
        {
            if (!wb_MainBrowser.IsBusy)
            {
                wb_MainBrowser.Navigate("http://google.com/");
            }
            else
            {
                MessageBox.Show("Please let the page finish loading!");
            }
        }

for some reason it shows me the hey message, I've tried creating a new project, but im ending up with the same, for no apparent reason, and I'm getting rather irritated :(.

Is there anyway i can make it only execute it once?

Regards
-Jaz

What are you actually asking? is it that you want to execute this once? or you don't want the hey message?

i just want it to be executed once :)

the hey message was just a test to see how many times the event was triggered :)

ok make an integer variable let's say count and update it in calling function and put condition on its value like

int count=0;
public void caller()
{
if(count==0)
{
function1();
count++;
}
else
{
MessageBox.Show("Over done");
}
}
public void function1()
{
}

Edited 5 Years Ago by abelLazm: n/a

Comments
Thanks for your help, it's very much appreciated :)

Worked like a charm, thank you so much! :D

Edited 5 Years Ago by Jazerix: n/a

This question has already been answered. Start a new discussion instead.