I'm trying to select a value from a second dropdown list which is updated dynamically.
Here is my code for the second dropdown:
HtmlElementCollection select = x.GetElementsByTagName("select");
foreach (HtmlElement el in select)
{
if (el.Name == "color")
{
foreach (HtmlElement ele in el.GetElementsByTagName("option"))
{
//MessageBox.Show(ele.InnerHtml);
if (ele.InnerText == "green")
{
ele.Focus();
ele.SetAttribute("selected", "selected");
el.InvokeMember("onchange");
ele.RemoveFocus();
break;
}
}
}
}
The code works but only if I use the MessageBox statement. If I comment the MessageBox line, the dropdown option won't be selected.
What event is the MessageBox raising ?
I don't have an explanation for the behavior that you are seeing but in my extensive work with WebBrowser controls in the past I have come across some unexplicable behaviors, too.
Anyway, here are a few things you can try:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.