C# get css property
I have an element in c#:
H开发者_开发问答tmlElement element = webBrowser1.Document.GetElementById("idName");
The site has an element
<ul id="idName" class="className">
In the css for this class is registered property of the background: url ('url')
. How do I know this property from c#?
System.Windows.Forms.HtmlElement.GetAttribute(string)
is what you want IMO.
simply call it passing the class and luckily it will return to you the value you're looking for.
You could use javascript to assign that value to an hidden form field, and then read the field's value in your C# code.
Would be nice to know why you're doing this though.
I believe you are going to have to parse the css file yourself. When you detect that an element has a class assigned, search the corresponding css file for that class. Then pull the properties for it and compare.
精彩评论