【发布时间】:2014-01-03 08:58:29
【问题描述】:
我需要从 webBrowser 控件中当前选择的选项中选择innerText。
这是 html 的表示:
<SELECT ID="F8">
<OPTION VALUE="option1">option1</OPTION>
<OPTION VALUE="option2" selected>option2</OPTION>
<OPTION VALUE="option3">option3</OPTION>
</SELECT>
这是我正在尝试的:
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;
}
}
}
...但它完全忽略了 if 语句并始终将 assigneeText.Text 的值分配给 option3 而不是选定的 option2 的值。
谁能告诉我我做错了什么?
【问题讨论】:
标签: c# html webbrowser-control innertext