Setting HTML Text Element value
Posted
by Gpx
on Stack Overflow
See other posts from Stack Overflow
or by Gpx
Published on 2010-05-16T06:38:55Z
Indexed on
2010/05/16
6:50 UTC
Read the original article
Hit count: 438
Hi,
in my C# WPF prog i´am trying to set a value of a HTML Text Element which is defined like:
<input name="tbBName" type="text" id="tbBName" tabindex="1" />
What i found about it and tried is:
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)webBrowser1.Document;
mshtml.HTMLInputTextElement tbName = (mshtml.HTMLInputTextElement)doc.getElementsByName("tbBName");
tbName.value = "Test";
But i got the exception:
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)).
I know what it says but i dont know which object i can use to access the Texbox.
Thanks for any answers.
© Stack Overflow or respective owner