[英]Can't input data into input field from VB.net
我正在尝试使用WebBrowser控件在多个输入字段上设置值。
<input type="text" name="Customer" maxlength="80" value="" style="background:#DCE4EF;width:100;border: 1px solid #2B589B">
我知道我无法使用WebBrowser1.Document.GetElementById,因为我没有ID。 我需要在三个具有不同名称的不同输入字段上执行三次。 是否可以,如果可以,我如何实现?
将name =“ Customer”更改为id =“ Customer”,然后使用document.GetElementById
string str = "new value"
一旦拥有元素element.SetAttribute("value", str)
也可以保留name =“ Customer”并使用document.All.GetElementsByName("Customer")[0].SetAttribute("value", str)
您可以使用以下代码获取任何属性:
Dim AllElementes As HtmlElementCollection = WebBrowser1.Document.All
For Each webpageelement As HtmlElement In AllElementes
If webpageelement.GetAttribute("name") = "Customer" Then
webpageelement.SetAttribute("value","YOUR TEXT HERE")
End If
Next
您可以将"name"
更改为任何标记中的任何其他元素。
但是如果是这样的话:
<h1>text here</h1>
请参阅我的问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.