Link to home
Start Free TrialLog in
Avatar of instaknow
instaknow

asked on

How to get the computed CSS styles that get applied to the element in the browser using .NET?

Hi All,

I have a web browser (System.Windows.Forms.WebBrowser) control in my VB.NET windows application. I load some URL into this control. Then I loop through all the element in WebBrowser1.Document.DomDocument.All using the mshtml.IHTMLElement as the element interface and try to get some of the properties of the elements (like id etc.).

What I also need to do is to be able to get the inherited computed styles getting applied to the elements from external (as well as inline) CSS. I have done a lot of research on the web and found  javascript solutions (using getComputedStyle), but haven't found any .NET solutions that I can use directly from VB.NET. I did see on MSDN that there is a IDisplayServices::GetComputedStyle Method (http://msdn.microsoft.com/en-us/library/aa752657(VS.85).aspx), but I am not able to use it from VB.NET. Looks like mshtml does not support it from VB.

Is there any other way or approach that I can use so that I can get the computed CSS styles getting applied to a particular element from VB.NET or C#.NET??? I really need to be able to get the computed CSS styles. Will greatly appreciate if some one will be able to help me out.
ASKER CERTIFIED SOLUTION
Avatar of silvera21
silvera21
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial