Trying to hook OnChange events for controls in browser control



Hello,

I have a simple C# application with a browser control in a form. I am
currently getting events for OnClicks so that I can log data regarding
what was clicked on, but I would also like to be able to detect when
the value of a control (editbox, checkbox, selectbox, etc.) has
changed.

From searching and reading previous posts it sounds like OnChange
events do not bubble up like OnClicks do so I cannot simply add an
event handler at a high level.

Here is what I did for the OnClicks:

in the DocumentCompleted
this.webBrowser1.Document.Click += new
HtmlElementEventHandler(Document_Click);

and my handler is
void Document_Click(object sender, HtmlElementEventArgs e)

For the OnChange I am first enumerating the elements on the page and
trying to add an event handler to each input type. Here is what I have

System.Collections.IEnumerator ieElem =
this.webBrowser1.Document.All.GetEnumerator();
while (ieElem.MoveNext())
{
if (((HtmlElement)ieElem.Current).DomElement.GetType().ToString()
== "mshtml.HTMLInputElementClass")
{
string sName = ((HtmlElement)ieElem.Current).Name;
string sInnerText = ((HtmlElement)ieElem.Current).InnerText;

???? attach an event handler
}
}

I have tried a bunch of different combinations things but nothing seems
to work.

How do I attach an OnChange event to the element?
What is the syntax of the Delegate?

Any help would be greatly appreciated.

Thanks,

Skordog

.


Loading