Veres Robert
Veres Robert

Reputation: 57

Put text into a textbox from a website in VB.NET

I want to know how to put text to a website's textbox with VB.NET. Like when you complete a textbox and press enter. Something like this:

Dim web as webbrowser

web.document.textbox(1).insert("text")

Upvotes: 0

Views: 7476

Answers (4)

Aim_life
Aim_life

Reputation: 1

I get a way that if u want to receive from the website itself another way I need to receive results from the website into the text box. U can use this method. first, make a web browser to load the page

WebBrowser1.Navigate("https://tools.keycdn.com/geo")

then this

    TextBox1.Text = WebBrowser1.Document.GetElementById("geoResult").InnerText

Upvotes: 0

DealSmoke
DealSmoke

Reputation: 1

This will help 100%:

webbrowser1.document.getElementById("yourtextboxidinwebsite").innertext = textbox1.text

Upvotes: 0

Mantra
Mantra

Reputation: 346

As giuseppe has suggested, you need to search for the element in the document and then set it's value property. for example following code logins into website by setting its userId and password textboxes and clicking the submit button.

Dim htmlDoc=WebBrowser1.Document
Dim elem_Input_UsrName As HtmlElement = htmlDoc.GetElementById("username")
Dim elem_Input_PssWrd As HtmlElement = htmlDoc.GetElementById("password")
Dim elem_Input_Submit As HtmlElement = getElementByClassName("Submit", "Input", htmlDoc)
If elem_Input_UsrName IsNot Nothing AndAlso elem_Input_PssWrd IsNot Nothing Then
   elem_Input_UsrName.SetAttribute("value", "[email protected]")
   elem_Input_PssWrd.SetAttribute("value", "yourpassoword")
   elem_Input_Submit.InvokeMember("click")
End If

Upvotes: 0

giuseppe
giuseppe

Reputation: 11

it would look something like this:

WebBrowser1.Document.GetElementById("login_password").SetAttribute("value", TextBox2.Text)

Upvotes: 1

Related Questions