fishmong3r
fishmong3r

Reputation: 1434

webBrowser .Url is not being applied

This one is mystical. I'm updating my webBrowser1 control from my code like this:

string hostname = textBox1.Text;
webBrowser1.Url = new Uri(@"http://mydomain/comp.php?compname=" + hostname);
webBrowser1.Refresh();

Every odd number tries work OK. Every even number tries simply refreshes the webBrowser with the last compname. So:

1. set textbox comp1 goes to http://mydomain/comp.php?compname=comp1
2. set textbox comp2 goes to http://mydomain/comp.php?compname=comp1
3. set textbox comp3 goes to http://mydomain/comp.php?compname=comp3
4. set textbox comp956 goes to http://mydomain/comp.php?compname=comp3
5. set textbox comp111 goes to http://mydomain/comp.php?compname=comp111
6. set textbox comp goes to http://mydomain/comp.php?compname=comp111
etc...

How on earth is that even possible?

Upvotes: 1

Views: 47

Answers (2)

bokibeg
bokibeg

Reputation: 2142

Try:

webBrowser1.Stop();
webBrowser1.Url = new Uri(@"http://mydomain/comp.php?compname=" + hostname);

Instead of the old code.

Upvotes: 1

dav_i
dav_i

Reputation: 28157

I don't think using Url then Refresh is the correct procedure.

Try doing

var uri = new Uri(@"http://mydomain/comp.php?compname=" + hostname);
webBrowser1.Navigate(uri);

Upvotes: 0

Related Questions