Why cannot edit/input text in .NET WebBrowser control on IE9+ system?
Posted by Admin L in .NET Programming on 19-11-2012. Tags: .NET Programming Experience, C# FAQ, C# Programming Experience, C# Skills, C# Q & A, .NET FAQ, .NET Skills, .NET Q & A, VB .NET Programming Experience, VB .NET Q & A, VB .NET FAQ, VB .NET Skills
Author: Nosa Lee
Original Address: https://www.seeksunslowly.com/edit-input-text-dot-net-webbrowser-control-ie9
To reprint this article, please indicate the source, thank you.
_____________________________________
For instance: your WebBrowser is named as wb, then the following code can let WebBrowser control to be editable:
[cc lang=”vbnet”]
Private Sub wb_DocumentCompleted(ByVal sender As Object, _
ByVal e As WebBrowserDocumentCompletedEventArgs) _
Handles wb.DocumentCompleted
wb.Document.Write(wb.DocumentText)
wb.Document.DomDocument.DesignMode = “on”
End Sub
[/cc]
Note: if you do not consider IE9, you only need to set DesignMode as “on”, so, the important sentence is: wb.Document.Write(wb.DocumentText), that is writing the HTML source code or WebBrowser compulsorily first.