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.

Help???

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.

Try putting it in the DocumentLoaded event.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.