开发者

RuntimeBinderException in IE object

开发者 https://www.devze.com 2023-03-03 05:50 出处:网络
Firstly, I should say that I need to use an Internet Explorer (IE9) object in my application, I can\'t use the webBrowser control. So, I want to emulate focus event on a field on a webpage:

Firstly, I should say that I need to use an Internet Explorer (IE9) object in my application, I can't use the webBrowser control. So, I want to emulate focus event on a field on a webpage:

webBrowser.Document.Forms[0].GetElementsByTagName("input")[0].InvokeMember("onFocus");
webBrowser.Document.Forms[0].GetElementsByTagName("input")[0].SetAttribute("value", "aaaa");
webBrowser.Document.Forms[0].GetElementsByTagName("input")[1].InvokeMember("onFocus");
webBrowser.Document.Forms[0].GetElementsByTagName("input")[1].SetAttribute("value", "bbbbb");

The webBrowser variable 开发者_如何转开发is public static SHDocVw.InternetExplorer webBrowser;. Its value is set to new SHDocVw.InternetExplorer();.

When the first line of the code is executed, I get an exception,

"System.MarshalByRefObject.InvokeMember(<...>)" Inaccessible due to protection level.

The function I use is private static. Maybe it's connected with the fact that IE's Document is dynamic?

So, how can I fix this exception? Or is there any other way to emulate focus on a field?

Thanks in advance.


One should use FireEvent() instead of InvokeMember().

0

精彩评论

暂无评论...
验证码 换一张
取 消