5 Replies - 394 Views - Last Post: 12 June 2013 - 03:30 PM Rate Topic: -----

#1 eltel2910  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-June 13

Same webpage always loads with webBrowser

Posted 12 June 2013 - 12:11 PM

I have a program that I wrote for sending messages to some of my friends through a website. It works fine, but for some reason I can't get it to work correctly with just one button click event. If I don't have a second button click for the SEND data method (whichs POSTs the data), it will always just keep sending the message to the same person, eventhough the new URL is loaded into the webBrowser URL*, but if I have that second click event all works fine. What am I missing?

*Using the debugger I see a new URL load with every iteration, but I do see on the HTTP debugger that the program is sending to the same URL each time

 private void button1_Click(object sender, EventArgs e)
    {
        ListBox();
    }
 private void ListBox()
    {
        //gets name from ListBox        

        GetData();


    }

private void GetData()
    {

       webBrowser1.Navigate(inputURLID);

        //SendData ();  Always sends to the same person if I call from here, so I made a second button click and it works fine
    }

private void button2_Click(object sender, EventArgs e)// works fine like this
     {
         webBrowser1.document.GetElementById("subject").SetAttribute("value", textBox2.Text);//To (username)

         webBrowser1.document.GetElementById("message").SetAttribute("value", richTextBox1.Text);//Subject

         webBrowser1.document.GetElementById("Submit").InvokeMember("click");//Message

     } 


Is This A Good Question/Topic? 0
  • +

Replies To: Same webpage always loads with webBrowser

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: Same webpage always loads with webBrowser

Posted 12 June 2013 - 12:28 PM

You probably have your events out of whack. Why not put a breakpoint at the top of your click method and follow it line by line until you see where the problem is.
Was This Post Helpful? 0
  • +
  • -

#3 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 469
  • View blog
  • Posts: 3,199
  • Joined: 12-January 10

Re: Same webpage always loads with webBrowser

Posted 12 June 2013 - 12:43 PM

I agree with modi -- also shouldn't you clear out the old url before resetting it to a new one? maybe it is just confusing itself?
Was This Post Helpful? 0
  • +
  • -

#4 eltel2910  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-June 13

Re: Same webpage always loads with webBrowser

Posted 12 June 2013 - 03:03 PM

View PostDarenR, on 12 June 2013 - 12:43 PM, said:

I agree with modi -- also shouldn't you clear out the old url before resetting it to a new one? maybe it is just confusing itself?

Yes. I have ran it with the debugger and I don't see anything obvious. I just code for a hobby, so I am no expert....when you say "clear out the old url before resetting it to a new one" how would you do that?
Was This Post Helpful? 0
  • +
  • -

#5 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Same webpage always loads with webBrowser

Posted 12 June 2013 - 03:25 PM

View Posteltel2910, on 12 June 2013 - 04:03 PM, said:

View PostDarenR, on 12 June 2013 - 12:43 PM, said:

I agree with modi -- also shouldn't you clear out the old url before resetting it to a new one? maybe it is just confusing itself?

Yes. I have ran it with the debugger and I don't see anything obvious. I just code for a hobby, so I am no expert....when you say "clear out the old url before resetting it to a new one" how would you do that?

You should show us your SendData() routine. As well, what is in inputURLID when you do the second Navigate? Also, are you using a DocumentCompleted() event? If not, you are probably trying to work with the first URL, as the next one is not loaded yet.

Cann't help you much with the code, as I am a VB.Net sorta guy, which is why I'm hanging around the VB.Net forum.
Was This Post Helpful? 1
  • +
  • -

#6 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3524
  • View blog
  • Posts: 12,031
  • Joined: 12-December 12

Re: Same webpage always loads with webBrowser

Posted 12 June 2013 - 03:30 PM

Moved to C#. Please post in the correct forum.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1