Rank: Member Groups: Member
Joined: 7/17/2020 Posts: 14
|
Hi,
we try to replace the default .net WebBrowser control. Currently we use these 2 events:
this._WebBrowser.Navigating += this.IDSWebShopBrowser_Navigating; ((SHDocVw.InternetExplorer)this._WebBrowser.ActiveXInstance).BeforeNavigate2 += this.IE_BeforeNavigate2;
Here we access the DocumentText:
private void IDSWebShopBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e) { var content = ((WebBrowser)sender).DocumentText;
Here we need the URL and the PostData:
private void IE_BeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel) {
What is the preferred way with your control?
thx
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, You can handle BeforeRequestLoad event. The code will be something like this:
Code: C#
private void WebView_BeforeRequestLoad(object sender, BeforeRequestLoadEventArgs e)
{
//This event is fired for every resource load, including sub resources
//such as JavaScript, images, CSS, etc. So it is important to check
//ResourceType here
if (e.Request.ResourceType == ResourceType.MainFrame)
{
//Get the WebView object
EO.WebBrowser.WebView webView = sender as EO.WebBrowser.WebView;
//Get the current HTML
string currentHtml = webView.GetHtml();
//Get the new Url. You can get many other data from the Request object
//such as cookies, form post data, etc.
string newUrl = e.Request.Url;
.....
}
}
Hope this helps. Thanks!
|
Rank: Member Groups: Member
Joined: 7/17/2020 Posts: 14
|
Thank you!
|