473,320 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Microsoft WebBrowser control

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?
--
-Bill Cousert
wr*******@yahoo.com

moderator of http://groups.yahoo.com/group/c-sharp-programming
Nov 13 '05 #1
4 6947
"Bill Cousert" <wr*******@yahoo.com> wrote in message
news:eu**************@TK2MSFTNGP12.phx.gbl...
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

--
Please post questions to the newsgroup - everyone benefits.
This post is provided "AS IS" with no warranties, and confers no rights
Sample code subject to http://www.microsoft.com/info/cpyright.htm
Nov 13 '05 #2

"Peter Torr (MS)" <pt***@microsoft.com> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...
"Bill Cousert" <wr*******@yahoo.com> wrote in message
news:eu**************@TK2MSFTNGP12.phx.gbl...
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.


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
wr*******@yahoo.com


Peter

--
Please post questions to the newsgroup - everyone benefits.
This post is provided "AS IS" with no warranties, and confers no rights
Sample code subject to http://www.microsoft.com/info/cpyright.htm

Nov 13 '05 #3
"Bill Cousert" <wr*******@yahoo.com> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...
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/b...w/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

--
Please post questions to the newsgroup - everyone benefits.
This post is provided "AS IS" with no warranties, and confers no rights
Sample code subject to http://www.microsoft.com/info/cpyright.htm
Nov 13 '05 #4

"Peter Torr (MS)" <pt***@microsoft.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
"Bill Cousert" <wr*******@yahoo.com> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...
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/b...w/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.

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Noozer | last post by:
I've just installed the Mozilla ActiveX control. I'm trying to replace the Microsoft WebBrowser control with the Mozilla control, but I'm getting a type mismatch error trying to get the browser...
9
by: ASP .NET Newbie | last post by:
How can I run a WebBrowser control using ASP.NET/VB.NET? I know I can use the WebClient to get the page data, but I need to be able to use the WebBrowser (AxWebBrowser)? Thanks, Chad
1
by: Tuong | last post by:
I have a situation where i have a form that contains a webbrowser control. With this I was able to implement an application that can browse websites. One particular website i visited opens up...
28
by: BobAchgill | last post by:
Has anyone had success with using this Com control? When I add it into my tool box and drop it into my form it says in the properties that the Document and LocationURL are read only. (they are...
0
by: Jim Hubbard | last post by:
How would I implement the IDispatch interface to handle the following in VB.Net <BEGIN> Controlling Download and Execution The WebBrowser Control gives you control over what it downloads,...
4
by: Bootstrap Bill | last post by:
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?
8
by: Prosperz | last post by:
Hi, I would like to make thumbnails of web page by capture content of a WebBrowser. By example, capture http://www.google.com. I used WebBrowser control with Framework 2.0. I try this : ...
1
by: L. Chernov | last post by:
Hello, I am trying to work with .Net 2005 WebBrowser object, and put it on a "Windows control library" (embedded in a user control class) and then I am executing it from an ASP.Net webform(with...
4
by: Steve Richter | last post by:
I would like to build an HTML stream as a string and have the WebBrowser control render that HTML. Then on PostBack, or whatever it is called, I would like my code to be the one that receives what...
5
by: kimiraikkonen | last post by:
Hi, I couldn't find a necessary class which shows when mouse hovers on a link in Webbrowser control. Think of there's a status bar(text), when mouse comes on a link, the URL must be shown in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.