On my form, I have a webbrowser, that navigates to nothing on start. But on webBrowser navigated I have this code, but the msbBox keeps showing on start up.

if (webBrowser1.DocumentText.Contains("Hello"))
            {
                this.Text = "iUltimate - Cheating Zone - " + txtUser.Text;
            }
            else
            {
                MessageBox.Show("Error, please try again. This might be caused by misspelling your username or pass. Only V.I.P. Members can sign in.");
            }

Code should be,

if(SearchButtonIsClicked){
            if (webBrowser1.DocumentText.Contains("Hello"))
            {
                this.Text = "iUltimate - Cheating Zone - " + txtUser.Text;
            }
            else
            {
                MessageBox.Show("Error, please try again. This might be caused by misspelling your username or pass. Only V.I.P. Members can sign in.");
            }
 }

The SearchButtonIsClicked... doesnt seem to work even with my button name.

Even though you don't navigate anywhere, for some reason the webbrowser control fires the navigate even to no-where.

What adatapost is trying to say is that you should check to see if your button has been clicked and only execute your code if it has.

Thank you guys for all your effort... I used adatapost method and checked if a button was enabled.

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