Welcome Guest Search | Active Topics | Sign In | Register

Replace .net WebBrowser Options
PraKom Software GmbH
Posted: Saturday, July 18, 2020 2:59:04 AM
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
eo_support
Posted: Saturday, July 18, 2020 2:58:24 PM
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!
PraKom Software GmbH
Posted: Sunday, July 19, 2020 4:21:14 AM
Rank: Member
Groups: Member

Joined: 7/17/2020
Posts: 14
Thank you!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.