using the webbrowser ctl from C# 
Author Message
 using the webbrowser ctl from C#

When using the WebBrowser control from a VB application, i
can call the Navigate2 method with only a URL in the form
of a string ("http:www.msn.com") and bang it goes there.  

In my C# code, im trying to call the Navigate2 method from
a button_click event.  However, there is no version of the
Navigate2 method that takes just a string.  It requires
ref paramaters passed also.  help ?  how about just using
some variables of type 'Object', and just passing them in ?

Here is what the VB object browser says about the
Navigate2 method.  In C#, the paramaters have the ref
object modifiers added.
Sub Navigate2(URL, [Flags], [TargetFrameName], [PostData],
[Headers])

help ?



Sat, 11 Sep 2004 23:34:17 GMT  
 using the webbrowser ctl from C#
jobob,

    The reason for this is that optional parameters are not supported in
.NET.  Instead, you have method overloading.  To make up for this in COM
interop, all the parameters are exposed on the method, and it is up to you
to pass in the "missing" parameters (which VB does under the covers).

    To make your call, do the following:

// Declare a dummy object to pass in the missing values.
object pobjMissing = System.Reflection.Missing.Value;

// webBrowser1 is the Web Browser control.
webBrowser1.Navigate2("http://www.someplace.com", ref pobjMissing, ref
pobjMissing, ref pobjMissing, ref pobjMissing);

    Hope this helps.

--
               - Nicholas Paldino [.NET MVP]


Quote:
> When using the WebBrowser control from a VB application, i
> can call the Navigate2 method with only a URL in the form
> of a string ("http:www.msn.com") and bang it goes there.

> In my C# code, im trying to call the Navigate2 method from
> a button_click event.  However, there is no version of the
> Navigate2 method that takes just a string.  It requires
> ref paramaters passed also.  help ?  how about just using
> some variables of type 'Object', and just passing them in ?

> Here is what the VB object browser says about the
> Navigate2 method.  In C#, the paramaters have the ref
> object modifiers added.
> Sub Navigate2(URL, [Flags], [TargetFrameName], [PostData],
> [Headers])

> help ?



Sat, 11 Sep 2004 23:44:46 GMT  
 using the webbrowser ctl from C#
http://groups.google.ca/groups?q=htmlbrowser+lutz&hl=en&selm=%23%2487...
Quote:

> When using the WebBrowser control from a VB application, i
> can call the Navigate2 method with only a URL in the form
> of a string ("http:www.msn.com") and bang it goes there.  

> In my C# code, im trying to call the Navigate2 method from
> a button_click event.  However, there is no version of the
> Navigate2 method that takes just a string.  It requires
> ref paramaters passed also.  help ?  how about just using
> some variables of type 'Object', and just passing them in ?

> Here is what the VB object browser says about the
> Navigate2 method.  In C#, the paramaters have the ref
> object modifiers added.
> Sub Navigate2(URL, [Flags], [TargetFrameName], [PostData],
> [Headers])

> help ?



Sun, 12 Sep 2004 02:32:11 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Ctl-C, Ctl-X and Ctl-V in RichEditCtrl

2. TAB problems in WebBrowser ctl

3. Key Event in WebBrowser ctl

4. use webbrowser ctl to display .eml files

5. use Webbrowser ctl to display .eml files

6. Excel Automation using .NET/C# and Webbrowser Control

7. Using MS WebBrowser Control in C#

8. Using MS WebBrowser Control in C#

9. Is there a MFC Class for using the WebBrowser Control (Without using COM)

10. troubles with events in C# and WebBrowser, etc.

11. How To: View Source for WebBrowser control from C# program

12. Webbrowser with C#

 

 
Powered by phpBB® Forum Software