473,396 Members | 1,866 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,396 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 6951
"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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.