Search code examples
mshtmlmicrosoft.mshtml

mshtml fireevent onchange not firing


I am unable to fire an "onchange" event in mshtml. Can you please tell me what I am doing wrong here.

HTMLSelectElement element = (HTMLSelectElement)this.HTMLDocument.all.item(controlId, 0);
IHTMLElement e = element as IHTMLElement;
IHTMLDocument4 doc = e.document as IHTMLDocument4;
object dummy = null;
object eventObj = doc.CreateEventObject(ref dummy);
HTMLSelectElementClass se = element as HTMLSelectElementClass;
se.FireEvent("onchange", ref eventObj);

I am getting variable "se" as null. I got this piece of code from another link http://www.itwriting.com/phorum/read.php?3,1507

Can anyone help me with this.

Thanks, Sam


Solution

  • I had tried all those which Sheng mentioned but didn't work.

    This issue was solved by injecting javascript code for "onchange" and executing it. It worked.