By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,455 Members | 1,385 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,455 IT Pros & Developers. It's quick & easy.

Getting html source inside a frame (webbroser control)

P: n/a
Hi,

in C# I'm able to access a webbrowser control with the following code and
print out all "tags":
IHTMLDocument2 HTMLDocument = (IHTMLDocument2)browser.Document;

IHTMLElementCollection links = HTMLDocument.links;
foreach (HTMLAnchorElementClass el in links)
{
listBox1.Items.Add(el.outerHTML);

}

This works fine for a non-frameset page...But doesn't work for a page with a
frameset. Could anyone tell me how to print all "text-tags" from all frames
within the frameset?

Tanks in advance,

Randy

Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
You can access the frame documents like this (wb1 is a WebBrowser Control):

wb1.Document.Window.Frames[intFrameIndexThatIWant].Document.Body

HTH

DalePres
MCAD, MCDBA, MCSE
"Randy" <Ra***@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
Hi,

in C# I'm able to access a webbrowser control with the following code and
print out all "tags":
IHTMLDocument2 HTMLDocument = (IHTMLDocument2)browser.Document;

IHTMLElementCollection links = HTMLDocument.links;
foreach (HTMLAnchorElementClass el in links)
{
listBox1.Items.Add(el.outerHTML);

}

This works fine for a non-frameset page...But doesn't work for a page with
a
frameset. Could anyone tell me how to print all "text-tags" from all
frames
within the frameset?

Tanks in advance,

Randy

Nov 16 '05 #2

P: n/a

Thanks a lot!

Randy
"DalePres" wrote:
You can access the frame documents like this (wb1 is a WebBrowser Control):

wb1.Document.Window.Frames[intFrameIndexThatIWant].Document.Body

HTH

DalePres
MCAD, MCDBA, MCSE
"Randy" <Ra***@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
Hi,

in C# I'm able to access a webbrowser control with the following code and
print out all "tags":
IHTMLDocument2 HTMLDocument = (IHTMLDocument2)browser.Document;

IHTMLElementCollection links = HTMLDocument.links;
foreach (HTMLAnchorElementClass el in links)
{
listBox1.Items.Add(el.outerHTML);

}

This works fine for a non-frameset page...But doesn't work for a page with
a
frameset. Could anyone tell me how to print all "text-tags" from all
frames
within the frameset?

Tanks in advance,

Randy


Nov 16 '05 #3

P: n/a
Hi again,

and how can I do that with the IHTMLFramesCollection2?

Thanks in advance,

Randy

"DalePres" wrote:
You can access the frame documents like this (wb1 is a WebBrowser Control):

wb1.Document.Window.Frames[intFrameIndexThatIWant].Document.Body

HTH

DalePres
MCAD, MCDBA, MCSE
"Randy" <Ra***@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
Hi,

in C# I'm able to access a webbrowser control with the following code and
print out all "tags":
IHTMLDocument2 HTMLDocument = (IHTMLDocument2)browser.Document;

IHTMLElementCollection links = HTMLDocument.links;
foreach (HTMLAnchorElementClass el in links)
{
listBox1.Items.Add(el.outerHTML);

}

This works fine for a non-frameset page...But doesn't work for a page with
a
frameset. Could anyone tell me how to print all "text-tags" from all
frames
within the frameset?

Tanks in advance,

Randy


Nov 16 '05 #4

P: n/a
Unfortunately, my current WebBrowser based project is in version 2.0 of the
..Net Framework. The WebBrowser control in version 2.0 does not allow the
Windows.Forms.HtmlDocument object to be cast as IHTMLDocument2 so I can't
duplicate your code and try it out.

The best news is that in version 2.0, the Windows.Forms.HtmlDocument object
has a method GetElementsByTagName which makes what you're trying to do
simple and, in fact, I am using it to do what you're trying to do: read
elements of a specific type from a frame document.

The IHTMLDocument2 doesn't have the same method but the IHTMLDocument3 does.
Of course, IHTMLDocument3 doesn't expose the links property. Perhaps in
combination, you can come up with something that will get you what you want.

DalePres

"Randy" <Ra***@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
Hi again,

and how can I do that with the IHTMLFramesCollection2?

Thanks in advance,

Randy

"DalePres" wrote:
You can access the frame documents like this (wb1 is a WebBrowser
Control):

wb1.Document.Window.Frames[intFrameIndexThatIWant].Document.Body

HTH

DalePres
MCAD, MCDBA, MCSE
"Randy" <Ra***@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
> Hi,
>
> in C# I'm able to access a webbrowser control with the following code
> and
> print out all "tags":
>
>
> IHTMLDocument2 HTMLDocument =
> (IHTMLDocument2)browser.Document;
>
> IHTMLElementCollection links = HTMLDocument.links;
>
>
> foreach (HTMLAnchorElementClass el in links)
> {
> listBox1.Items.Add(el.outerHTML);
>
> }
>
> This works fine for a non-frameset page...But doesn't work for a page
> with
> a
> frameset. Could anyone tell me how to print all "text-tags" from all
> frames
> within the frameset?
>
> Tanks in advance,
>
> Randy
>


Nov 16 '05 #5

P: n/a
Thanks a lot!!!

"DalePres" wrote:
Unfortunately, my current WebBrowser based project is in version 2.0 of the
..Net Framework. The WebBrowser control in version 2.0 does not allow the
Windows.Forms.HtmlDocument object to be cast as IHTMLDocument2 so I can't
duplicate your code and try it out.

The best news is that in version 2.0, the Windows.Forms.HtmlDocument object
has a method GetElementsByTagName which makes what you're trying to do
simple and, in fact, I am using it to do what you're trying to do: read
elements of a specific type from a frame document.

The IHTMLDocument2 doesn't have the same method but the IHTMLDocument3 does.
Of course, IHTMLDocument3 doesn't expose the links property. Perhaps in
combination, you can come up with something that will get you what you want.

DalePres

"Randy" <Ra***@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
Hi again,

and how can I do that with the IHTMLFramesCollection2?

Thanks in advance,

Randy

"DalePres" wrote:
You can access the frame documents like this (wb1 is a WebBrowser
Control):

wb1.Document.Window.Frames[intFrameIndexThatIWant].Document.Body

HTH

DalePres
MCAD, MCDBA, MCSE
"Randy" <Ra***@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
> Hi,
>
> in C# I'm able to access a webbrowser control with the following code
> and
> print out all "tags":
>
>
> IHTMLDocument2 HTMLDocument =
> (IHTMLDocument2)browser.Document;
>
> IHTMLElementCollection links = HTMLDocument.links;
>
>
> foreach (HTMLAnchorElementClass el in links)
> {
> listBox1.Items.Add(el.outerHTML);
>
> }
>
> This works fine for a non-frameset page...But doesn't work for a page
> with
> a
> frameset. Could anyone tell me how to print all "text-tags" from all
> frames
> within the frameset?
>
> Tanks in advance,
>
> Randy
>


Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.