在 C# WPF 程序中,我试图设置定义的 HTMLText
元素的值:
<input name="tbBName" type="text" id="tbBName" tabindex="1" />
我尝试了以下方法:
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)webBrowser1.Document;
mshtml.HTMLInputTextElement tbName = (mshtml.HTMLInputTextElement)doc.getElementsByName("tbBName");
tbName.value = "Test";
但我得到以下异常:
Unable to cast COM object of type 'System.__ComObject' to interface type 'mshtml.HTMLInputTextElement'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3050F520-98B5-11CF-BB82-00AA00BDCE0B}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
我知道它在说什么,但我不知道我可以使用哪个对象来访问文本框。
我究竟做错了什么?