I am going to a URL in the form web browser. Once it loads I want to remove some elements and show a modified version to the user. My code compiles but I can't get the web browser in the form change what it is displaying. Been trying everything... I can't save page to html and then load that in the web browser because the online web page has an .aspx application I would like to use.
In this example I am trying to remove all <p>
html paragraph and one div with ID ContentPlaceHolder1_UpdatePanel1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace toolBrowser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
webBrowser1.ScriptErrorsSuppressed = true;
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
dynamic htmldoc = webBrowser1.Document.DomDocument as dynamic;
dynamic node = htmldoc.getElementTagName("p") as dynamic;
node.parentNode.removeChild(node);
var htmlElement2 = webBrowser1.Document.GetElementById("ContentPlaceHolder1_UpdatePanel1");
htmlElement2.InnerText = "";
}
}
}