Update html TEXTAREA from VB.NET in WebBrowser object

I have loaded a html page into a webbrowser object and I want to add some text to the textarea field on the html page. However when I run the code below the text is not added to the textarea. Do I need to run some kind of update or similar to update the web page or am I using the wrong method?
Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("textarea")

For Each curElement As HtmlElement In theElementCollection
Dim controlName As String = curElement.GetAttribute("name").ToString
                If controlName = "TheNameOfTheField" Then
                   curElement.InnerHtml = "test"
                End If
            Next

Open in new window

jes12345Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StealthyDevCommented:
Are you writing this in server?
jes12345Author Commented:
No this is a client app..
CodeCruiserCommented:
>GetElementsByTagName("textarea")
May be because no element is found by that tag name! Try this approach

http://vbcity.com/blogs/jatkinson/archive/2009/12/12/programmatically-entering-and-data-using-the-webbrowser-control.aspx

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

yu0307Commented:
Here is a little piece of codes. it works for me at least, based on VS2008, .net. EZWeb is the webbroweser. and the rest you should be able to understand. I hope codes below will help you a little bit.:)

        Dim tx As HtmlDocument = Me.EZweb1.Document
        For Each curElement As HtmlElement In tx.GetElementsByTagName("textarea")
            Dim controlName As String = curElement.GetAttribute("name").ToString
            If controlName = "TheNameOfTheField" Then
                curElement.InnerHtml = "test"
            Else
                curElement.InnerHtml = "wahahahahhaha"
            End If
        Next
        Me.EZweb1.Document.Body.InnerHtml = tx.Body.InnerHtml
StealthyDevCommented:
Try this:

Dim theElementCollection As HtmlElementCollection = Me.WebBrowser1.Document.GetElementsByTagName("textarea")

For Each curElement As HtmlElement In theElementCollection
Dim controlName As String = curElement.GetAttribute("name").ToString
                If controlName = "TheNameOfTheField" Then
                   curElement.InnerHtml = "test"
                End If
            Next
yu0307Commented:
A even shorter version of the code as i thought you will also like. it works on mine again. below is the piece of code hope you like it :)

For Each curElement As HtmlElement In Me.EZweb1.Document.GetElementsByTagName("textarea")
            Dim controlName As String = curElement.GetAttribute("name").ToString
            If controlName = "TheNameOfTheField" Then
                curElement.InnerHtml = "test"
            End If
        Next

Open in new window

jes12345Author Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.