/// <summary>Gets the selected input by the given name attribute. /// E.g. there may be more than one input element (such as with radios); this is the active one.</summary> public Element this[string name] { get{ List <Element> allWithName = Element.getElementsByAttribute("name", name); if (allWithName.Count == 0) { return(null); } if (allWithName.Count == 1) { return(allWithName[0]); } // We have more than one. If it's a radio, return the one which is selected. // Otherwise, return the last one. InputTag tag = ((InputTag)(allWithName[0].Handler)); if (tag.Type == InputType.Radio) { // Which is selected? foreach (Element radio in allWithName) { if (((InputTag)(radio.Handler)).Checked) { return(radio); } } } return(allWithName[allWithName.Count - 1]); } }
/// <summary>Gets all elements with the given attribute. May include this element or any of it's kids.</summary> /// <param name="property">The name of the attribute to find. E.g. "id".</param> /// <param name="value">Optional. The value that the attribute should be; null for any value.</param> /// <returns>A list of all matches.</returns> public List <Element> getElementsByAttribute(string property, string value) { return(html.getElementsByAttribute(property, value)); }