How to use IHTMLDocument2 with .NET 2.0 Webbrowser
-
VS 2005 C# Express, .NET 2.0 The following code causes the Body member of the Webbrowser control to be set to null. Why? mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2) this.webBrowser1.Document.DomDocument; doc2.designMode = "On"; I am trying to programmatically select an element () in a web page listbox () the way a user would with the left mouse button. So, far I've found nothing that will do this.
-
VS 2005 C# Express, .NET 2.0 The following code causes the Body member of the Webbrowser control to be set to null. Why? mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2) this.webBrowser1.Document.DomDocument; doc2.designMode = "On"; I am trying to programmatically select an element () in a web page listbox () the way a user would with the left mouse button. So, far I've found nothing that will do this.
cweeks78681 wrote:
I am trying to programmatically select an element (OPTION) in a web page listbox (SELECT) the way a user would with the left mouse button.
What does that have to do with setting designMode to ON? :confused: Would you know how to do that in a javascript running in the HTML page? If not you should learn how to do that first because it is the same thing. The DOM in WebBrowser is the same DHTML DOM you use in javascript. You want to get a reference to the DHTML listbox element and set it's .selectedIndex property to the desired index.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum led mike
-
cweeks78681 wrote:
I am trying to programmatically select an element (OPTION) in a web page listbox (SELECT) the way a user would with the left mouse button.
What does that have to do with setting designMode to ON? :confused: Would you know how to do that in a javascript running in the HTML page? If not you should learn how to do that first because it is the same thing. The DOM in WebBrowser is the same DHTML DOM you use in javascript. You want to get a reference to the DHTML listbox element and set it's .selectedIndex property to the desired index.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum led mike
> What does that have to do with setting designMode to ON? It was a shot in the dark. I thought maybe the HTMLDocument was in some kind of read-only state because I have NEVER found a way to modify a page in the web browser. Some kind of exception is always thrown. One said something about an access violation.