VB.NET WebBrowser Take textarea value
I can not take the value from a web textarea the code is as follows
<input type="text" name="ID1" id="subject" size="20" value="TEST1" />
<input type="text" name="ID2" id="subject" size="20" value开发者_如何学Python="TEST2" />
I want to insert the value TEST1 and TEST2 in a vb.net form and show messagebox with the value thanks I hope you can help me, I beg your pardon for my bad English
The name field does not really matter. You want the id field to be different. You can keep them the same if you want. Try this:
<input type="text" name="ID1" id="ID1" size="20" value="TEST1" />
<input type="text" name="ID2" id="ID2" size="20" value="TEST2" />
I'm not sure what you mean by show messagebox. Are you talking about a javascript alert()
call?
Also, note this is not actually VB.NET. The code you have posted is just html. If you want to interact with the values on the serverside you would need code that looks something like this in your aspx page:
<asp:TextBox id="id1" columns="20" text="Test1" runat="server" />
Dim HtmlElementcoll As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("textarea")
For Each elem As HtmlElement In HtmlElementcoll
' Check the attributtes you want
If elem.GetAttribute("name") = "status" Then
'Check even the text if you want
' If elem.InnerText = "Sign In" Then
'Invoke your event
elem.SetAttribute("value", "hey")
'elem.InvokeMember("click")
'End If
End If
Next
you can fill a textbox without an id like this i have used getAttribute method to get the name of the field and setAttribute to set the value of the textbox.
精彩评论