Windows Forms Binding to HTMLElement Events

A

AMDRIT

Hello Everyone,

We have a production WinForms Application that uses a WebBrowser to display
readonly data. In the html document we have SPAN elements that facilitate
menu selections. We also have a TABLE object that is bound to an XML Data
Island, each row of the table has an option to "View Details" or "Delete"

When a user clicks a SPAN object we would set the WebBrowser's Status Text
to the desired command, then back to "Ready". The windows form would then
capture the statustext change event and process the command. We were
testing the impact IE7 has with this application and found that this
solution no longer works.

We have now decided to listen for the click events of these SPAN objects
from within the windows form. This is working wonderful except for the SPAN
objects in the databound table. Here in lies my question, how do we get the
click events to fire in our windows form?

Below is a snippet of code that we use to add the event handler, first for
the top level menu items, then for the menu items on each row of the table.

For Each objElement As HtmlElement In
objHTML.All.Item("menusection").GetElementsByTagName("SPAN")

'Top level menu Items are seperated with " | ", so ignore them
If Not objElement.InnerText.Contains("|") Then
AddHandler objElement.Click, AddressOf MenuItemClicked
Trace.WriteLine(String.Format("{0}, {1}", objElement.TagName,
objElement.InnerText))
End If

Next

For Each objElement As HtmlElement In
objHTML.All.Item("menutable").GetElementsByTagName("SPAN")

'The only two menu items that we want to listen for are "Delete" and
"View Details"
If objElement.InnerText.Contains("Delete") Or
objElement.InnerText.Contains("View Details") Then
AddHandler objElement.Click, AddressOf MenuItemClicked
Trace.WriteLine(String.Format("{0}, {1}", objElement.TagName,
objElement.InnerText))
End If

Next


Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top