Why cannot edit/input text in .NET WebBrowser control on IE9+ system?

Posted by NosaLee in .NET Programming on 19-11-2012. Tags: , , , , , , , , , , ,

Author: Nosa Lee
Original Address: http://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:

1
2
3
4
5
6
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

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.

Post a comment