943,741 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 716
  • C# RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 18th, 2009
0

Activate WebBrowser

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dave starkey is offline Offline
9 posts
since Sep 2009
Sep 18th, 2009
0

Re: Activate WebBrowser

C# Syntax (Toggle Plain Text)
  1. webBrowser1.Url = new Uri("http://microsoft.com");
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 18th, 2009
0

Re: Activate WebBrowser

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.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Sep 18th, 2009
0

Re: Activate WebBrowser

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
Attached Files
File Type: zip IPSetv3.zip (65.8 KB, 13 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dave starkey is offline Offline
9 posts
since Sep 2009
Sep 18th, 2009
0

Re: Activate WebBrowser

It works I tried it
Please tell me what's the compilation error...
Last edited by Ramy Mahrous; Sep 18th, 2009 at 10:10 am.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 18th, 2009
0

Re: Activate WebBrowser

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dave starkey is offline Offline
9 posts
since Sep 2009
Sep 18th, 2009
0

Re: Activate WebBrowser

Yes, you can but it inside button click event handler or set it from control properties
Uri = http://microsoft.com
Believe me it works
Last edited by Ramy Mahrous; Sep 18th, 2009 at 11:13 am.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 18th, 2009
0

Re: Activate WebBrowser

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

Dave
Attached Files
File Type: zip MainForm.zip (66.9 KB, 21 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dave starkey is offline Offline
9 posts
since Sep 2009
Sep 18th, 2009
0

Re: Activate WebBrowser

In the project you uploaded the only thing I see for the browser is:
C# Syntax (Toggle Plain Text)
  1. void WebBrowser1DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
  2. {
  3. webBrowser1.Url = new Uri("http://microsoft.com");
  4. }

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:
C# Syntax (Toggle Plain Text)
  1. void BrowseFaultyAPClk(object sender, EventArgs e)
  2. {
  3. webBrowser1.Navigate(@"http://www.google.com");
  4. /*
  5.   string FaultyAPAddr = "http://" + FaultyAPIPOct1Num.Value + "."
  6. + FaultyAPIPOct2Num.Value + "."
  7. + FaultyAPIPOct3Num.Value + "."
  8. + FaultyAPIPOct4Num.Value + ".";
  9. Process ProcessIeFaultyAP = new System.Diagnostics.Process();
  10. ProcessIeFaultyAP.StartInfo.FileName = "iexplore.exe";
  11. ProcessIeFaultyAP.StartInfo.WorkingDirectory = @"C:\WINDOWS\ie7";
  12. ProcessIeFaultyAP.StartInfo.Arguments = String.Format(FaultyAPAddr);
  13. ProcessIeFaultyAP.Start();
  14.   */
  15. }
  16.  
  17. void WebBrowser1DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
  18. {
  19. //webBrowser1.Url = new Uri("http://microsoft.com");
  20. }
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Sep 21st, 2009
0

Re: Activate WebBrowser

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dave starkey is offline Offline
9 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Including DLLs for use in other programs
Next Thread in C# Forum Timeline: Remove duplicates from a List<Rectangle> C#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC