'C# Winform Webbrowser not updating after document text update
Good Morning,
I have a Web browser embedded within a C# winform. When loading the web-browser, it loads in a local file and displays the page with no issues.
I then have a button with an OnClick method which does the following:
private void button1_Click(object sender, EventArgs e) {
this.webBrowser1.Navigate("about:blank");
HtmlDocument doc = this.webBrowser1.Document;
doc.Write(String.Empty);
this.webBrowser1.DocumentText = //PathToDocumentText;
}
This was taken from this SO question and causes the web browser to freeze up. On hover shows the cursor with the loading spinning icon.
I am simply wanting to change the document text from one local file to another (both work if I load them in manually OnLoad).
Any help appreciated.
Solution 1:[1]
this.webBrowser1.Navigate("about:blank");
this.webBrowser1.Document.OpenNew(false);
this.webBrowser1.Document.Write(//pathtoFile);
this.webBrowser1.Refresh();
This does the trick, Thanks to anyone who looked at this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |