简体   繁体   English

HTML WebBrowser VB.Net上的复选框未打勾

[英]Check box not ticking on HTML WebBrowser VB.Net

I am trying to automatically tick a text box on a vb.net web browser when the page loads the HTML of the check box is as follows 当页面加载复选框的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);">

This is what I am trying to use to tick the box but it doesn't seem to work 这是我试图用来勾选的框,但似乎不起作用

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

Any help is appreciated 任何帮助表示赞赏

You can achieve what you seek by doing the following: 您可以通过执行以下操作来实现您的目标:

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

(You will need to add a reference to microsoft.mshtml) (您将需要添加对microsoft.mshtml的引用)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM