471,319 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Difference between vs2005 WebBrowser and AxWebBrowser components?

I'm looking to user a web browser component in VS2005.

I like the functionality in the AXWebBrowser component (from ActiveX
controls page) that allows me to do this:

mshtml.HTMLDocument doc;

doc = (mshtml.HTMLDocument)this.SecureWebBrowser.Documen t;

mshtml.HTMLButtonElement ButtonTest =
(mshtml.HTMLButtonElement)doc.all.item("ctl00$Cent erContent$ctl09$SignUp",
null);

ButtonTest.disabled = true;
Is this possible with the WebBrowser component that I can drop onto my
WinForm in VS2005 - I do not see that capability exposed - what are the
advances/disadvantages of each?

TIA!

Jan 16 '06 #1
6 11102
This should be possible. The WebBrowser control is basically the active
X wrapper, with some extra code to make the interop easier.

There are new elements defined in the System.Windows.Forms namespace
which represent the HTML elements. However, if you want, you should be able
to get at the original objects (through a cast or a property on the object)
and cast to the interfaces exposed through a reference to MSHTML.tlb.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ESmith" <el**********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm looking to user a web browser component in VS2005.

I like the functionality in the AXWebBrowser component (from ActiveX
controls page) that allows me to do this:

mshtml.HTMLDocument doc;

doc = (mshtml.HTMLDocument)this.SecureWebBrowser.Documen t;

mshtml.HTMLButtonElement ButtonTest =
(mshtml.HTMLButtonElement)doc.all.item("ctl00$Cent erContent$ctl09$SignUp",
null);

ButtonTest.disabled = true;
Is this possible with the WebBrowser component that I can drop onto my
WinForm in VS2005 - I do not see that capability exposed - what are the
advances/disadvantages of each?

TIA!

Jan 16 '06 #2
"ESmith" <el**********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I like the functionality in the AXWebBrowser component (from ActiveX
controls page) that allows me to do this:

mshtml.HTMLDocument doc;

doc = (mshtml.HTMLDocument)this.SecureWebBrowser.Documen t; Is this possible with the WebBrowser component that I can drop onto my
WinForm in VS2005 - I do not see that capability exposed - what are the
advances/disadvantages of each?


AxWebBrowser is an automatically generated wrapper, whereas WebBrowser is
manually customized for .NET. The WebBrowser control has more convenient
methods, such as loading and reading HTML as a string, and should be better
behaved - some people have strange issues with the AxWebBrowser especially
when nested within panels etc.

The snag as you say is that WebBrowser doesn't expose anything like the full
functionality of ShDocVw. However, you can get a reference to the underlying
ActiveX control via the ActiveXInstance property. See here for an example of
when this is necessary:

http://www.itwriting.com/blog/?postid=273

Overall I'd be inclined to use WebBrowser over the AxWebBrowser; or make an
even better wrapper of your own :-)

Tim
Read my tech blog:
http://www.itwriting.com/blog

Jan 16 '06 #3
Eliana,
Is this possible with the WebBrowser component that I can drop onto my
WinForm in VS2005 - I do not see that capability exposed - what are the
advances/disadvantages of each?


For simple browser programming, the 2005 WB is MUCH easier to use, but its
power is limited. If you want/need full control, you'll have to wrap it
yourself. The primary functionality that I've found missing in WB 2005 is
frame/iframe support. The control abstracts browsing to the degree that it
hides the fact that navigation events fire for each frame on the page. For
advanced WB programming, you must be aware of this and have control of it.
--
Colin Neller
http://www.colinneller.com/blog

Jan 16 '06 #4
My £0.02 worth...

I've just had to refactor a pile of code that used the AxWebBrowser version
(now uses WebBrowser) because I was getting obscure versioning issues on
some computers (casting complaints to/from mshtml types) - presumably
something to do with the version on the build machine. The WebBrowser
control (which presumably uses AxWebBrowser underneath) didn't appear to
have any such difficulty.

Of course, it helps that my requirements were fairly simple ;-p

Marc
Jan 17 '06 #5
Thanks to everyone for there replies!

P.S.

Marc, given the value of the Pound, looks like your opinion is carrying
more weight :-)

"Marc Gravell" <mg******@rm.com> wrote in message
news:Oh**************@TK2MSFTNGP11.phx.gbl...
My £0.02 worth...

I've just had to refactor a pile of code that used the AxWebBrowser
version (now uses WebBrowser) because I was getting obscure versioning
issues on some computers (casting complaints to/from mshtml types) -
presumably something to do with the version on the build machine. The
WebBrowser control (which presumably uses AxWebBrowser underneath) didn't
appear to have any such difficulty.

Of course, it helps that my requirements were fairly simple ;-p

Marc

Jan 17 '06 #6
I'm a .NET noob, so forgive me if this is obvious:

Can anyone give me a hint about how to hook up events from the WebBrower?

The following lets me get the IWebBrowser2 interface:
SHDocVw.IWebBrowser2 pWeb = (SHDocVw.IWebBrowser2)webBrowser1.ActiveXInstance;

However, I can't figure out how to go from that to the delegate:
SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHan dler

I know I can reach down and get the IConnectionPointContainer, etc and I
assume I could maybe wire it up myself, but that seems like the hard way to
go about it.

Thanks
Doug
"Tim Anderson" wrote:
"ESmith" <el**********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I like the functionality in the AXWebBrowser component (from ActiveX
controls page) that allows me to do this:

mshtml.HTMLDocument doc;

doc = (mshtml.HTMLDocument)this.SecureWebBrowser.Documen t;

Is this possible with the WebBrowser component that I can drop onto my
WinForm in VS2005 - I do not see that capability exposed - what are the
advances/disadvantages of each?


AxWebBrowser is an automatically generated wrapper, whereas WebBrowser is
manually customized for .NET. The WebBrowser control has more convenient
methods, such as loading and reading HTML as a string, and should be better
behaved - some people have strange issues with the AxWebBrowser especially
when nested within panels etc.

The snag as you say is that WebBrowser doesn't expose anything like the full
functionality of ShDocVw. However, you can get a reference to the underlying
ActiveX control via the ActiveXInstance property. See here for an example of
when this is necessary:

http://www.itwriting.com/blog/?postid=273

Overall I'd be inclined to use WebBrowser over the AxWebBrowser; or make an
even better wrapper of your own :-)

Tim
Read my tech blog:
http://www.itwriting.com/blog

Mar 8 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Richard Steele | last post: by
1 post views Thread by Adam Barker | last post: by
9 posts views Thread by ASP .NET Newbie | last post: by
reply views Thread by Arthur Dent | last post: by
6 posts views Thread by Dave Booker | last post: by
11 posts views Thread by Anil Gupte | last post: by
3 posts views Thread by =?Utf-8?B?R2F1cmF2?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.