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

Recommended Answers

All 10 Replies

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

It works I tried it :|
Please tell me what's the compilation error...

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

Yes, you can but it inside button click event handler or set it from control properties
Uri = http://microsoft.com
Believe me it works :)

Oops, I uploaded the wrong files in the last post. Here is the one with the Browser object.

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!

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.