implement button click in html

Posted by vbNewbie on Stack Overflow See other posts from Stack Overflow or by vbNewbie
Published on 2010-05-24T20:50:16Z Indexed on 2010/05/25 16:11 UTC
Read the original article Hit count: 261

Filed under:
|

I have been trying to execute a button event in html page that displays additional content on the web page. I am getting a null reference error when using the getelementbyid and not sure how to change this. Here is the html reference I need to engage:

<div class="button" style="float:none;width:180px;margin:20px auto 30px;"><a href="#" id="more" style="width:178px">Show more ?</a></div>

        </div>

and here is my code:

                Dim wb As New WebBrowser
                wb.Navigate(fromUrl)


                While wb.ReadyState <> WebBrowserReadyState.Complete
                    Application.DoEvents()
                End While
                Debug.Write(wb.DocumentText)
                Dim htmlElements As HtmlElementCollection = wb.Document.GetElementsByTagName("<a")
                If Not wb.Document Is Nothing Then
                    Try
                        If wb.DocumentText.Contains("more") Then
                            If wb.Document.GetElementById("more").GetAttribute("href") Then
                                wb.Document.GetElementById("more").InvokeMember("#")
                            End If
                        End If
                    Catch ex As Exception
                        MessageBox.Show(ex.Message.ToString)
                    End Try
                End If

I appreciate any ideas.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about visual-studio-2008