H
holder
Folks, I have a simple web page with frames. I am trying to automate
internet explorer to display the page and allow access to its frames.
Here is the sample code :
using mshtml;
static void Main(string[] args)
{
SHDocVw.InternetExplorer explorer = null;
explorer = new InternetExplorer();
object nada = null;
explorer.Navigate("file://" + "c:\\temp\\xx" + "/frame.htm", ref nada, ref
nada, ref nada, ref nada);
explorer.Visible = true;
IWebBrowser2 browser;
browser = (IWebBrowser2)explorer;
IHTMLDocument2 doc = (IHTMLDocument2)browser.Document;
FramesCollection frames = (FramesCollection) doc.frames; // <<<======
exception
}
The browser launches and shows the page. Here is the web page:
<html>
<head>
<title>Title of page</title>
</head>
<frameset id="top" rows="25%,15%,15%,15%,15%,15%">
<frame id="a" >
<frame id="b" >
<frame id="c" >
<frame id="d" >
<frame id="e" >
<frame id="f" >
</frameset>
</html>
The frames field of the doc variable when accessed is throwing an invalid
cast exception.
Obviously, I have done something wrong. Can someone advise?
thanks,
bob
internet explorer to display the page and allow access to its frames.
Here is the sample code :
using mshtml;
static void Main(string[] args)
{
SHDocVw.InternetExplorer explorer = null;
explorer = new InternetExplorer();
object nada = null;
explorer.Navigate("file://" + "c:\\temp\\xx" + "/frame.htm", ref nada, ref
nada, ref nada, ref nada);
explorer.Visible = true;
IWebBrowser2 browser;
browser = (IWebBrowser2)explorer;
IHTMLDocument2 doc = (IHTMLDocument2)browser.Document;
FramesCollection frames = (FramesCollection) doc.frames; // <<<======
exception
}
The browser launches and shows the page. Here is the web page:
<html>
<head>
<title>Title of page</title>
</head>
<frameset id="top" rows="25%,15%,15%,15%,15%,15%">
<frame id="a" >
<frame id="b" >
<frame id="c" >
<frame id="d" >
<frame id="e" >
<frame id="f" >
</frameset>
</html>
The frames field of the doc variable when accessed is throwing an invalid
cast exception.
Obviously, I have done something wrong. Can someone advise?
thanks,
bob