I'm developing a windows form that opens a web application page. I'm obliged to use the COM AxWebBrowser for this goal. the problem is when a window.Open() action is executed in the web page, the new page is opened in my axWebBrowser and another blank page is shown .I need to force the new window to open in the blank page without affecting the main page. I tried the code below but it doesn't work fine:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyProject.MyNamespace
{
public partial class PopupWindow : Form
{
#region Fields
private PopupWindow _popupWindow;
#endregion
#region Ctr
public PopupWindow()
{
this.InitializeComponent();
this.axWebBrowser.Silent = true;
this.axWebBrowser.NewWindow3 += new AxSHDocVw.DWebBrowserEvents2_NewWindow3EventHandler(axWebBrowser_NewWindow3);
this.FormClosing += PopupWindow_FormClosing;
this.Shown += new EventHandler(PopupWindow_Shown);
}
private void axWebBrowser_NewWindow3(object sender, AxSHDocVw.DWebBrowserEvents2_NewWindow3Event e)
{
this._popupWindow = null;
this._popupWindow = new PopupWindow();
this._popupWindow.WindowState = FormWindowState.Maximized;
this._popupWindow.AXWebBrowser.RegisterAsBrowser = true;
e.ppDisp = this._popupWindow.AXWebBrowser.Application;
this._popupWindow.Visible = true;
}
#endregion
#region Properties
public AxSHDocVw.AxWebBrowser AXWebBrowser
{
get { return this.axWebBrowser; }
}
#endregion
#region Methods
private void PopupWindow_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
}
private void PopupWindow_Shown(object sender, EventArgs e)
{
this.Size = new Size(this.Width + 2, this.Height + 2);
}
#endregion
}
}
Thank you for your help!