954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Activate WebBrowser

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

dave starkey
Newbie Poster
9 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 
webBrowser1.Url = new Uri("http://microsoft.com");
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

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.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

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

Attachments IPSetv3.zip (65.77KB)
dave starkey
Newbie Poster
9 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

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

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

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

dave starkey
Newbie Poster
9 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

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

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

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

Dave

Attachments MainForm.zip (66.93KB)
dave starkey
Newbie Poster
9 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

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");
		}
sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

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

dave starkey
Newbie Poster
9 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

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!

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You