Using Web Browser COM control in C#

  • Thread starter Thread starter johnguilbert
  • Start date Start date
J

johnguilbert

HI,

Really apreciated if someone could help.

I am trying to automate a number of clicks etc for a web site that has
been developed. However, this site has a number of frames in it. The
frame id = "header"contains a login I need to auto-populate. However
the syntax I am trying is not correct. How do I access a frame's html
from the main (base) document?

I have:

// retrieve base document
HTMLDocument myDoc = new HTMLDocumentClass();
myDoc = (HTMLDocument) axWebBrowser1.Document;

// this line is incorrect - it doesn't like this syntax
HTMLFrameElement otxtloginframe = (HTMLFrameElement)
myDoc.frames("header");

// retrieve document in frame 'header'
HTMLDocument myDoc2 = new HTMLDocumentClass();
myDoc2 = (HTMLDocument) otxtloginframe.document;

Any help really appreciated.

Thanks

John.
 
HI,

Really apreciated if someone could help.

I am trying to automate a number of clicks etc for a web site that has
been developed. However, this site has a number of frames in it. The
frame id = "header"contains a login I need to auto-populate. However
the syntax I am trying is not correct. How do I access a frame's html
from the main (base) document?

I have:

// retrieve base document
HTMLDocument myDoc = new HTMLDocumentClass();

Don't use "new" here. You're creating a document just to destroy it in the
next line of code.
myDoc = (HTMLDocument) axWebBrowser1.Document;

// this line is incorrect - it doesn't like this syntax
HTMLFrameElement otxtloginframe = (HTMLFrameElement)
myDoc.frames("header");

This probably wants to be:

myDoc.frames["header"];

However, I can't be sure, since you didn't include the error you received.

BTW, which version of .NET are you using? There's a managed web browser
control in .NET 2.0.
 
Back
Top