populating an <input> on a webpage in a webbrowser control

vbdotnetnoob

New member
Joined
May 16, 2010
Messages
3
Programming Experience
Beginner
Here is my situation...

I know the code to find the input boxes in question.. basically the html is like so
HTML:
Expand Collapse Copy
<input type="text" name="username" class="inputbox">

i know enough to use

VB.NET:
Expand Collapse Copy
WebBrowser1.Document.Forms.GetElementsByName("username")
to find the text box...but I need to know how to send the contents of say TextBox1.text to the form on the web page...i can't figure it out for crap...I just assume give up and use sendkeys to tab to the textbox even thought its 80% unreliable....


Any help would be appreciated...thanks
 
To create a html element

VB.NET:
Expand Collapse Copy
        Dim vBrowser As WebBrowser
        Dim vDocument As HtmlDocument
        vDocument = vBrowser.Document
        Dim vDiv As HtmlElement = vDocument.CreateElement("div")

To add items to the element

VB.NET:
Expand Collapse Copy
vDiv.InnerHtml = "Hello world"

To add the element to the form

VB.NET:
Expand Collapse Copy
vDocument.Body.AppendChild(vDiv)
 
I would try the following:
VB.NET:
Expand Collapse Copy
For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
            If element.GetAttribute("name") = "username" Then
                element.SetAttribute("value", TextBox1.Text)
            End If
        Next
 
Back
Top