Microsoft WebBrowser control

P

Peter Torr \(MS\)

Bill Cousert said:
I have a Windows Form that uses the Microsoft WebBrowser control. If I load
an HTML file into the control that contains Jscript code, can the Jscript
code call a C# function in my Windows Form?

Hi Bill,

Try adding your C# object as the "window.external" object. Then JScript
should be able to manipulate it.

Peter
 
B

Bill Cousert

Peter Torr (MS) said:
Hi Bill,

Try adding your C# object as the "window.external" object. Then JScript
should be able to manipulate it.

Hi Peter,

Would I do this by adding a reference? Assume my function is named test. How
would I call it from JScript?


Thanks,

-Bill Cousert
(e-mail address removed)
 
P

Peter Torr \(MS\)

Bill Cousert said:
Hi Peter,

Would I do this by adding a reference? Assume my function is named test. How
would I call it from JScript?

Actually, I'm not sure how easy it will be to use the external object in C#
with WinForms. Looking at:

http://msdn.microsoft.com/workshop/browser/overview/overview.asp

it seems you have to do work in an DocUIHost interface which (presumably)
WinForms implements for you. Maybe you can figure out a way around that.

Anyway, the next best option is to call into IE to get a handle on the
script block, then use Reflection to invoke a member on the script that will
accept a callback object (your C# object) for later use. Kind of messy, but
it should work.

Peter
 
B

Bill Cousert

Peter Torr (MS) said:
Actually, I'm not sure how easy it will be to use the external object in C#
with WinForms. Looking at:

http://msdn.microsoft.com/workshop/browser/overview/overview.asp

it seems you have to do work in an DocUIHost interface which (presumably)
WinForms implements for you. Maybe you can figure out a way around that.

Anyway, the next best option is to call into IE to get a handle on the
script block, then use Reflection to invoke a member on the script that will
accept a callback object (your C# object) for later use. Kind of messy, but
it should work.

Peter
Thank you! I see I have my work cut out for me. I will post the results when
I figure this out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top