Dear All,
I have dropped a WebBrowser control onto my form but It will not display the webpage I have set the code to navigate to. Snippet is - APBrowsePage.Navigate("http://www.microsoft.com"); .
Where APBrowsePage is the control name.

Dave

Zip your project and upload it. You can do this by clicking "Go Advanced" next to "Post Quick Reply", and in the next screen click on manage attachments.

Ramy,
I have already tried to convert the URL to URI but that doesnt work either. Scott - The project should be attached - not sure what you needed so I put everything in.

Thanks
Dave

Ramy,
Theres no error - the control is just blank when I run the exe. Does the line of code need to defined in a particular event that I am not yet handling?

Dave

In the project you uploaded the only thing I see for the browser is:

void WebBrowser1DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
		{
			webBrowser1.Url = new Uri("http://microsoft.com");
		}

That is in the document complete event but I don't see anywhere that initially tell the navigator to browse. You should not be changing the browser's URL in the complete event because when it finishes loading a page it will call that event, triggering another page load, and it will loop.

I made these changes and it works:

void BrowseFaultyAPClk(object sender, EventArgs e)
		{
      webBrowser1.Navigate(@"http://www.google.com"); 
			/*
      string FaultyAPAddr = "http://" + FaultyAPIPOct1Num.Value + "."
											+ FaultyAPIPOct2Num.Value + "."
											+ FaultyAPIPOct3Num.Value + "."
											+ FaultyAPIPOct4Num.Value + ".";
			Process ProcessIeFaultyAP = new System.Diagnostics.Process();
			ProcessIeFaultyAP.StartInfo.FileName = "iexplore.exe";
			ProcessIeFaultyAP.StartInfo.WorkingDirectory = @"C:\WINDOWS\ie7";
			ProcessIeFaultyAP.StartInfo.Arguments = String.Format(FaultyAPAddr);
			ProcessIeFaultyAP.Start();
       */ 
		}
		
		void WebBrowser1DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
		{
			//webBrowser1.Url = new Uri("http://microsoft.com");
		}

Dear All,
Thanks for your help - I've now got it working. I had been using the DocumentCompleted event because this was automatically created when I double clicked on the object.

Dave

I'm glad you got it working

Please mark this thread as solved if you have found an answer to your original question and good luck!

This article has been dead for over six months. Start a new discussion instead.