WebBrowserClass returning system.__comobject instead of string
Posted on 2004-08-01
I have a WebBrowserClass object called Explorer contained in my C# object.
I use the following code to access the element with an id of "footerClientArea" of the currently loaded page:
HTMLDocument htmlDocument = (HTMLDocument)Explorer.Document;
e = htmlDocument.getElementById("footerClientArea");
string s = "";
s = e.getAttribute("style", 0).ToString().ToLower();
e = null;
htmlDocument = null;
What I am expecting is a message box containing the value of the "style" attribute, however, all I get is "system.__comobject"
it is strange, because when I display a message box with e.innerHTML, it correctly displays the HTML inside the element. I am assuming that I need to cast the return value of getAttribute to some object, but what object? Intellisense states that the return value of getAttribute is of type "object", which doesn't help. I know from the documentation that it should be returning a string, but the compiler won't accept a the value into a string variable without a cast, and casting the return value to a string doesn't work either...
Any help would be greatly appreciated!