Trying to hook OnChange events for controls in browser control
- From: jeffskory@xxxxxxxxxxx
- Date: 25 Jan 2007 08:37:13 -0800
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.
events do not bubble up like OnClicks do so I cannot simply add anFrom searching and reading previous posts it sounds like OnChange
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
.
- Prev by Date: Re: Onchange is fired after BeforeNavigate
- Next by Date: System.InvalidCastException : QueryInterface for interface Microsoft.ShDocVw.IWebBrowser2 failed
- Previous by thread: for darleen: truly artistic keyword searchable - kaz zomse - (1/1)
- Next by thread: System.InvalidCastException : QueryInterface for interface Microsoft.ShDocVw.IWebBrowser2 failed
- Index(es):
Loading