1

I have an element in c#:

HtmlElement 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#?

2
  • is this css being defined in a separate stylesheet? Commented Dec 9, 2010 at 18:41
  • yeah, in a separate stylesheet Commented Dec 9, 2010 at 19:23

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried using GetAttribute ("background"), it returns null. GetAttribute ("style") returns "System.__ComObject" string.
I guess that you must pass either "css" or "class" and what the method returns is a string AFAIK.
0

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.