Last post Apr 06, 2009 04:58 AM by mcowan
Feb 16, 2009 04:20 PM|srhone|LINK
Is there a way to test if a control in enabled or disabled, background colors etc? So if I grab a <asp:imagebutton control and I tell if it is enabled?
Feb 16, 2009 06:18 PM|osbornm|LINK
These are all attributes that get added to the rendered html tag (disabled="disabled" for instence). You will need to get a collection of the attributes (HtmlElementAttributeReader) for that element and then verify using those. Bellow is some code showing
how to get the HtmlElementAttributeReader for an element.
HtmlPage page = new HtmlPage("SomePage.aspx");
HtmlElement element = page.Elements.Find("ControlID");
HtmlElementAttributeReader reader = element.GetAttributes();
//Some common attributes are strongly typed properties
//Other attributes are indexed through the collection
Mar 28, 2009 03:29 AM|mcowan|LINK
So this method only appears to work for a small number of properties.
Can you give an working example on how to find the property: naturalWidth inside of an Image Element?
Additionally, does any one have a clever way to use attributes to scan all the images on a page and see if they are loaded? I read that the naturalWidth will be set to 0 when an image doesn't load .. so I am trying to get that working.
Mar 28, 2009 09:00 PM|farmas|LINK
I am not familiar with the "naturalWidth" attribute. You are saying that this attribute exists on the HTML DOM but you can't get to it when you do imageElement.GetAttributes() ? If so, then this sounds like a bug that we should to take a look at that.
Apr 01, 2009 12:52 AM|mcowan|LINK
So using Chrome - Inspect Element on an Image .. you can see the HTMLImageElement has a set of properties:
Apr 06, 2009 01:01 AM|farmas|LINK
Thanks! I've logged a bug for this. We'll look at it for the next refresh.
Apr 06, 2009 04:58 AM|mcowan|LINK
Thanks alot. For reference here is another attempt to link images from my stupid google account.