Start New Discussion within our Software Development Community

Hi,
Im trying to click a button on http://www.threatexpert.com/submit.aspx but my code does not want to fill it in.
It fails are the

Form2.WebBrowser1.Document.GetElementById("txtEmail").SetAttribute("value", TextBox1.Text)
Form2.WebBrowser1.Document.GetElementById("File").InvokeMember("click")
        If Form2.WebBrowser1.Document.GetElementById("File").GetAttribute("value").ToString = vbNullString Then
            Form2.WebBrowser1.Document.GetElementById("File").InvokeMember("click")
            Form2.WebBrowser1.Document.GetElementById("txtEmail").SetAttribute("value", TextBox1.Text)
        Else
            WebBrowser1.Navigate("javascript: WebForm_DoPostBackWithOptions(btnSubmit")

        End If

What is wrong with my code

Cheers

See if this helps.
1 WebBrowser, 1 Button

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Not WebBrowser1.IsBusy Then '// make sure the webpage finished loading.
            If WebBrowser1.Url.AbsoluteUri = "http://www.threatexpert.com/submit.aspx" Then '// check if correct website.
                submitFileSampleToThreatExpert(WebBrowser1, TextBox1.Text) '// Submit File(your WebBrowser used, your TextBox containing the email)
            End If
        End If
    End Sub

    Private Sub submitFileSampleToThreatExpert(ByVal selectedWebBrowser As WebBrowser, ByVal myEmail As String)
        With selectedWebBrowser.Document
            .GetElementById("FileUpload").InvokeMember("click") '// click to Upload File.
            .GetElementById("txtEmail").SetAttribute("value", myEmail) '// add your Email.
            .GetElementById("chAgreeWithTerms").SetAttribute("checked", "checked") '// check the CheckBox for Terms and Conditions.
            .GetElementById("btnSubmit").InvokeMember("click") '// click the Submit btn.
        End With
    End Sub
This article has been dead for over six months. Start a new discussion instead.