0

Update on 06/06/2017: Thanks for jdweng's help, it seems that CsQuery doesn't have the method to get the offSetHeight & offSetWidth of an element.

I's using CsQuery in C# to analyse static HTML files, and want to get the Height and Width of an

element.

But it seems the IDomObject of csquery doesn't have the method to get the Height or Width.

Note that the Height or Width does not listed in the Style attribute, so I couldn't get them via:

Int32 ElementWidth = Int32.Parse(myDomObject.Styles["width"].replace("px","").Trim());

Also, the HTML files are saved in local drive, not generated via aspx file.

Any suggestions would be appreciated.

Rick
  • 322
  • 2
  • 8
  • Why do you expect it to be a style. Treat like a general Html Attribute. Also you need to parse a string so either get value or use ToString(). – jdweng May 29 '17 at 07:40
  • I don't expected it to be a style, just wanted to try all possibilities, and found that it was not in the Style attribute, also, tried: `myDomObject.HasAttribute("height")` or `myDomObject.HasAttribute("offsetheight")`, both return false, so I don't know what should I do. – Rick May 29 '17 at 07:47
  • Also, the `Attributes` property of the `myDomObject` only has two Attributes: one is Class and another is Style. – Rick May 29 '17 at 07:53
  • Put a break point on line after myDomObject is executed (F9). When break point is reached then highlight myDomObject and right click. The Add Watch. Look in watch and check the attributes to see what you really have – jdweng May 29 '17 at 07:56
  • I think I should be more specific: does csquery has any methods to get the `offsetHeight` and `offsetWidth` property of an HTML element just like jQuery? – Rick May 29 '17 at 08:03

0 Answers0