Reputation: 566
Working with mshtml + SHDocVw.InternetExplorer was easy in vb. But I have no idea why it would be almost impossible to do that in c#. It makes no sense when it says cannot declare the object type inside the e.g html document. What I am stuck with is the alternatives to the codes below.
IE.Document.getElementByID("ID").value="string"
IE.Document.getElementByID("ID").click()
IE.Document.GetElementsByTagName("tagname")(index).click()
IE.Document.ParentWindow.Frames(index).Document
.GetElementsByTagName("tagname")(index).click()
IE.Document.GetElementsByTagName("tagname")(index).value="string"
IE.Document.ParentWindow.Frames(index).Document
.GetElementsByTagName("tagname")(index).value="string"
(using .net 3.5)
Update: Maybe I should have been more specific. The problem is not the brackets, he problem is that the c# does not allow me to call the methods inside the document property.
Upvotes: 1
Views: 2220
Reputation: 46
You have to cast objects to COM Interfaces:
var doc = IE.Document;
var element = ((IHTMLDocument3)doc).getElementByID("ID");
Upvotes: 1