troubleshooting Question

Webbrowser Control click event trapping

Avatar of Teknosoft
Teknosoft asked on
.NET ProgrammingVisual Basic.NETWeb Components
10 Comments1 Solution21397 ViewsLast Modified:
Hello Experts,

I am developing an application that will utilize the webbrowser control. (VB.NET 2005) I need to trap user interactions within the webbrowser to trigger an event.

I was able to trap link clicking within the webbrwoser but I am unable to trap button clicks and/or image button click to an event.

This is important for me to be able to know when the user clicks such buttons that I can read informations entered into the for prior to submittion.

I am not sure if this is possible or not please let me know what you think.

Thank you


'This is a code to trap the link clicking event hope it will help to get the button clicking event.
 
    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
 
        Dim olink As HtmlElement
        Dim olinks As HtmlElementCollection = WebBrowser1.Document.Links
 
        For Each olink In olinks
            olink.AttachEventHandler("onclick", AddressOf LinkClicked)
        Next
 
    End Sub
 
 
 
    Private Sub LinkClicked(ByVal sender As Object, ByVal e As EventArgs)
        Dim link As HtmlElement = WebBrowser1.Document.ActiveElement
        Dim url As String = link.GetAttribute("href")
 
        MsgBox("Link Clicked: " & link.InnerText & vbCrLf & _
                    "Destination: " & url)
    End Sub
ASKER CERTIFIED SOLUTION
armoghan

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros