MrG*_*les 2 .net html c# webforms mshtml
我可以使用mshtml完成我需要做的大部分工作,但是我对如何将复选框输入元素设置为"已检查"感到困惑.这是情况......
IHTMLElementCollection inputElements = (IHTMLElementCollection)doc.all.tags("input");
foreach (IHTMLElement el in inputElements)
{
string elementHtml = el.outerHTML;
string termsOfServiceIdentifier = "id=chkUTOS_ver2";
// select the Terms of Service checkbox
if (elementHtml.Contains(termsOfServiceIdentifier))
{
HTMLInputElement chkTOS = (HTMLInputElement)el;
chkTOS.@checked = true; // that's the solution. Thanks Wayne.
}
else
{
// do nothing - we're not interested in this element
}
}
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助!
格雷格
| 归档时间: |
|
| 查看次数: |
2911 次 |
| 最近记录: |