I am running this code:
HtmlElement.GetAttribute(\"onClick\")
To try and get access to the onClick attribute of that element, but all this
Sample code
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://stackoverflow.com/questions/9707869/system-comobject-is-returned-when-i-use-getattribute")
End Sub
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Dim a As HtmlElement = WebBrowser1.Document.GetElementById("portalLink").FirstChild
MsgBox(a.DomElement.attributes("onclick").value.ToString)
End Sub
First, you can try to determine type of the control; then cast your object to this type. Accessing properties of element is possible with this method.
For example, if your object is a "div" contains an "onclick" method, you must convert your com object to mshtml.HTMLDivElement
(You must add assembly "mshtml.dll" into your project for using mshtml class); then you can look for "onclick" attribute in outerHTML
property.
if (doc.GetElementById("id-of-div").GetAttribute("onclick").Equals("System.__ComObject"))
{
mshtml.HTMLDivElement docCOM = (mshtml.HTMLDivElement)doc.GetElementById("id-of-div").DomElement;
string onClickStr = docCOM.outerHTML.[some string or regex operations here];
}