Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27080

VS 2010 Submit button on webbrowser with htmlelement

$
0
0
Okay, so this website http://dogwars.com/app/

Im making an app where you can login and stuff.

the login button on the website:

HTML Code:

<div style="margin-left: 77px; margin-top: 20px; height: 40px;">
  <a href="#" onclick="document.getElementById('loginForm').submit();" class="button"><span>Login</span></a>
  </div>


for my automatic submit button on VB.net I use this:

Code:

If curElement.GetAttribute("onclick").Equals("document.getElementById('loginForm').submit();") Then
            curElement.InvokeMember("click")
        End If


But it will not log in automatically... and i'm puzzled as to why it doesn't..?

Could someone help me out?

here is my full code:

Code:

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

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

    For Each curElement As HtmlElement In theElementCollection

        Dim controlName As String = curElement.GetAttribute("name").ToString

        If controlName = "email" Then

            curElement.SetAttribute("Value", TextBox1.Text)

        ElseIf controlName = "password" Then

            curElement.SetAttribute("Value", TextBox2.Text)

        End If

    Next


    theElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
    For Each curElement As HtmlElement In theElementCollection
        If curElement.GetAttribute("onclick").Equals("document.getElementById('loginForm').submit();") Then
            curElement.InvokeMember("click")
        End If
    Next
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class


Viewing all articles
Browse latest Browse all 27080

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>