Threw an exception of type 'System.InvalidCastException'



Hi everyone:

I met a trouble about MSHTML program, the detail as follw:

first I cast document.all.item("date1", null) to IHTMLElement, it
success, then I access its properties, it throw exeception like this:
'element2.innerText' threw an exception of type
'System.InvalidCastException', anyone could give me some tips about
this, thanks in advanced.

NET Framework: 2.0
IDE: Visual Studio 2005
MSHTML: Microsoft.mshtml, Version 7.0.3300.0

sample code

-------------------------------------------------------------------------------------------------------------------------------------------
ShellBrowserWindow browerWindow = (new
ShellWindowsClass()).Item(0) as ShellBrowserWindow;
if(browerWindow == null) { MessageBox.Show("Cast object error");
return; }
HTMLDocumentClass document = browerWindow.Document as
HTMLDocumentClass;
HTMLInputElementClass element = document.all.item("date1", null)
as HTMLInputElementClass;
IHTMLElement element2 = document.all.item("date1", null) as
IHTMLElement;

MessageBox.Show(element.tagName); //correct code
MessageBox.Show(element2.tagName); // incorrect code ,throw
exceptions.

.