To demonstrate and simplify the problem, I created a C# windows form project with only a windows web browser (AxShDocVW.AxWebBrowser (fiWebBrsr)) placed on it. There is a Before_Navigate2 event on the form that determines if there is an Post data associated with the Navigate2 event. If Post data exists, a new instance of SHDocVw.InternetExplorer is created and passed the information from the BeforeNavigate2Event arguments and directed to navigate to the same web site. What is observed is that two instances of an internet explorer will be created. One will successfully navigate to the website indicated. The other one will be tracked by the code but it will be uninitialized. This is the problem I'm trying to resolve. How can the second instance of the internet explorer be prevented and the one being tracked by the code be caused to navigate to the website. I'm using Visual Studio 2008, Internet Explorer 7 and the project is in C#. The code that is associated with the form is shown below:
Expand|Select|Wrap|Line Numbers
- namespace Test
- {
- public partial class frmSrch : Form
- {
- public frmSrch()
- {
- InitializeComponent();
- }
- private void Form1_Shown(object sender, EventArgs e)
- {
- this.fiWebBrwsr.Navigate("http://oregon.jobing.com/");
- }
- private void fiWebBrwsr_BeforeNavigate2(object sender, AxSHDocVw.DWebBrowserEvents2_BeforeNavigate2Event e)
- {
- if (!(e.postData == null))
- {
- SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();
- ie.Visible = true;
- ie.Navigate2(ref e.uRL, ref e.flags, ref e.targetFrameName,ref e.postData,ref e.headers);
- e.cancel = true;
- }
- }
- }
- }