复选框没有在HTML WebBrowser VB.Net上打勾

时间:2016-05-16 17:35:12

标签: html asp.net vb.net

我试图在页面加载复选框的HTML时自动勾选vb.net Web浏览器上的文本框,如下所示

<input checked="checked" class="checkbox" id="order_terms" name="order[terms]" type="checkbox" value="1" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);">

这就是我想用来勾选方框,但它似乎无法正常工作

WebBrowser2.Document.GetElementById("order_terms").SetAttribute("checked", "True")

感谢任何帮助

1 个答案:

答案 0 :(得分:0)

您可以通过以下方式实现您的目标:

Dim Document As mshtml.HTMLDocument = DirectCast(WebBrowser2.Document, mshtml.HTMLDocument)
Dim Input As mshtml.HTMLInputElement = TryCast(Document.getElementById("order_terms"), mshtml.HTMLInputElement)

If Input IsNot Nothing Then
    input.checked = false 'Uncheck the checkbox
End If

(您需要添加对microsoft.mshtml的引用)