I need to select the innerText
from the currently selected option in the webBrowser control.
Here is a representation of the html:
<SELECT ID="F8">
<OPTION VALUE="option1">option1</OPTION>
<OPTION VALUE="option2" selected>option2</OPTION>
<OPTION VALUE="option3">option3</OPTION>
</SELECT>
Here is what I am trying:
if (webBrowser1.Document.GetElementById("F8") != null)
{
HtmlElement selectF8 = webBrowser1.Document.GetElementById("F8");
foreach (HtmlElement item in selectF8.Children )
{
if (item.GetAttribute("selected") != null)
{
assigneeText.Text = item.InnerText;
}
}
}
... but it completely ignores the if statement and always assigns assigneeText.Text
the value of option3
instead of the value of the selected option2
.
Can someone please tell me what I am doing wrong?