public string getChoseOption(HtmlElement elem) { HtmlElementCollection optionCollection = elem.GetElementsByTagName("option"); foreach (HtmlElement OptionElem in optionCollection) { if (OptionElem.GetAttribute("selected") == "True") { return(OptionElem.GetAttribute("value")); } } return(""); }
//----------------------OPTIONS---------------------- public void set_options_elem(HtmlElement elem, string option_name) { HtmlElementCollection optionCollection = elem.GetElementsByTagName("option"); foreach (HtmlElement OptionElem in optionCollection) { if (OptionElem.InnerText == option_name) { OptionElem.SetAttribute("selected", "selected"); break; } } optionCollection[0].SetAttribute("selected", null); }
public void set_options(string inner_text) { HtmlElementCollection collect = webBrowser.Document.GetElementsByTagName("select"); foreach (HtmlElement selectElem in collect) { if (selectElem.InnerHtml.IndexOf(inner_text) > 0) { HtmlElementCollection optionCollection = selectElem.GetElementsByTagName("option"); foreach (HtmlElement OptionElem in optionCollection) { if (OptionElem.InnerText == inner_text) { OptionElem.SetAttribute("selected", "selected"); break; } } optionCollection[0].SetAttribute("selected", null); break; } } }