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.
instaknowAsked:
Who is Participating?
 
silvera21Commented:
No, you cannot get styles that are computed after the page reaches the browser with a server side language. You have to use javascript. You can however, use AJAX to pass the computed styles back to the server and send them back (if needed), and then use javascript again to apply any other changes if needed. But it must be a client side language that sets any info in the client.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.