473,387 Members | 1,535 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,387 software developers and data experts.

Calling HTML JScript from C# app

Hi
Can some good soul help on this. I need to call jscript functions from C#.
I have hosted a web control and displayed an html page successfully, but
just can't find a way to call jscript functions or set some var in the html.
There are some sample code in C++ using IDispatch but these are
beyond me. Looked at Tim Anderson's work on HTMLEditor but couldn't find any
example on calling jscript function. Read somewhere that the browser control
putproperty does not work for embed control.

Any help or sample code much appreciated.

regards
benc
QMatrix
Nov 16 '05 #1
5 5212
you need to use MSHTML. from the WebControl you can get to the document.

From here you need to use the DOM to do stuff with the document.

You can actually do anything here, and the MSHTML COM lib provides support
for calling submit methods, etc. with the HTML document.

This is all from memory and it's been a while, but start by adding a
reference in your project to the MSHTML lib, then you should be able to suss
it out from there.

HTH
Sam

"benc" <be**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
Hi
Can some good soul help on this. I need to call jscript functions from C#.
I have hosted a web control and displayed an html page successfully, but
just can't find a way to call jscript functions or set some var in the
html.
There are some sample code in C++ using IDispatch but these are
beyond me. Looked at Tim Anderson's work on HTMLEditor but couldn't find
any
example on calling jscript function. Read somewhere that the browser
control
putproperty does not work for embed control.

Any help or sample code much appreciated.

regards
benc
QMatrix

Nov 16 '05 #2
thanks, sam
i know this and is using the mshtml com and IHTMLDocument2, etc. but
just can't see how to call a jscript function. The putproperty function is
the way to go, but just does not work with the browser control.

any other help?
thanks

"Sam Martin" wrote:
you need to use MSHTML. from the WebControl you can get to the document.

From here you need to use the DOM to do stuff with the document.

You can actually do anything here, and the MSHTML COM lib provides support
for calling submit methods, etc. with the HTML document.

This is all from memory and it's been a while, but start by adding a
reference in your project to the MSHTML lib, then you should be able to suss
it out from there.

HTH
Sam

"benc" <be**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
Hi
Can some good soul help on this. I need to call jscript functions from C#.
I have hosted a web control and displayed an html page successfully, but
just can't find a way to call jscript functions or set some var in the
html.
There are some sample code in C++ using IDispatch but these are
beyond me. Looked at Tim Anderson's work on HTMLEditor but couldn't find
any
example on calling jscript function. Read somewhere that the browser
control
putproperty does not work for embed control.

Any help or sample code much appreciated.

regards
benc
QMatrix


Nov 16 '05 #3
yeah,

HTMLWindow2Class has a method called ExecScript i think.... hold on i'll
check...

ahhh, here ya go, and msdn example.
http://blogs.msdn.com/philoj/archive...25/119926.aspx

HTH

Sam

"benc" <be**@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
thanks, sam
i know this and is using the mshtml com and IHTMLDocument2, etc. but
just can't see how to call a jscript function. The putproperty function is
the way to go, but just does not work with the browser control.

any other help?
thanks

"Sam Martin" wrote:
you need to use MSHTML. from the WebControl you can get to the document.

From here you need to use the DOM to do stuff with the document.

You can actually do anything here, and the MSHTML COM lib provides
support
for calling submit methods, etc. with the HTML document.

This is all from memory and it's been a while, but start by adding a
reference in your project to the MSHTML lib, then you should be able to
suss
it out from there.

HTH
Sam

"benc" <be**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
> Hi
> Can some good soul help on this. I need to call jscript functions from
> C#.
> I have hosted a web control and displayed an html page successfully,
> but
> just can't find a way to call jscript functions or set some var in the
> html.
> There are some sample code in C++ using IDispatch but these are
> beyond me. Looked at Tim Anderson's work on HTMLEditor but couldn't
> find
> any
> example on calling jscript function. Read somewhere that the browser
> control
> putproperty does not work for embed control.
>
> Any help or sample code much appreciated.
>
> regards
> benc
> QMatrix
>
>


Nov 16 '05 #4
Hi Sam
Many thanks. You are most helpful.
I got it going now and only to find other issues. eg. plugin like SVG3 does
not quite behave the same in a hosted environment vis-a-vis in IE.

Also, any chance you know how to call C# from script? An example I had is
to set the script var with window.SetProperty(...,this) and then in the script
calling var.C#routineName should work. BUT not for mshtml.

thanks, regards
benc

"Sam Martin" wrote:
yeah,

HTMLWindow2Class has a method called ExecScript i think.... hold on i'll
check...

ahhh, here ya go, and msdn example.
http://blogs.msdn.com/philoj/archive...25/119926.aspx

HTH

Sam

"benc" <be**@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
thanks, sam
i know this and is using the mshtml com and IHTMLDocument2, etc. but
just can't see how to call a jscript function. The putproperty function is
the way to go, but just does not work with the browser control.

any other help?
thanks

"Sam Martin" wrote:
you need to use MSHTML. from the WebControl you can get to the document.

From here you need to use the DOM to do stuff with the document.

You can actually do anything here, and the MSHTML COM lib provides
support
for calling submit methods, etc. with the HTML document.

This is all from memory and it's been a while, but start by adding a
reference in your project to the MSHTML lib, then you should be able to
suss
it out from there.

HTH
Sam

"benc" <be**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
> Hi
> Can some good soul help on this. I need to call jscript functions from
> C#.
> I have hosted a web control and displayed an html page successfully,
> but
> just can't find a way to call jscript functions or set some var in the
> html.
> There are some sample code in C++ using IDispatch but these are
> beyond me. Looked at Tim Anderson's work on HTMLEditor but couldn't
> find
> any
> example on calling jscript function. Read somewhere that the browser
> control
> putproperty does not work for embed control.
>
> Any help or sample code much appreciated.
>
> regards
> benc
> QMatrix
>
>


Nov 16 '05 #5
hmm, i think the simple answer is you can't.

but you can handle the browsers events, like title change. as there's no
title shown it's one way you could pass info / exec commands in the host
app, one way i've made it work in an ancient version of PowerBuilder (a 4GL)
is to do this, setting the browser's title to be a specific string command,
i.e. "DOSOMETHING" and handling the titlechanged event.

just an idea

sam

"benc" <be**@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
Hi Sam
Many thanks. You are most helpful.
I got it going now and only to find other issues. eg. plugin like SVG3
does
not quite behave the same in a hosted environment vis-a-vis in IE.

Also, any chance you know how to call C# from script? An example I had is
to set the script var with window.SetProperty(...,this) and then in the
script
calling var.C#routineName should work. BUT not for mshtml.

thanks, regards
benc

"Sam Martin" wrote:
yeah,

HTMLWindow2Class has a method called ExecScript i think.... hold on i'll
check...

ahhh, here ya go, and msdn example.
http://blogs.msdn.com/philoj/archive...25/119926.aspx

HTH

Sam

"benc" <be**@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
> thanks, sam
> i know this and is using the mshtml com and IHTMLDocument2, etc. but
> just can't see how to call a jscript function. The putproperty function
> is
> the way to go, but just does not work with the browser control.
>
> any other help?
> thanks
>
> "Sam Martin" wrote:
>
>> you need to use MSHTML. from the WebControl you can get to the
>> document.
>>
>> From here you need to use the DOM to do stuff with the document.
>>
>> You can actually do anything here, and the MSHTML COM lib provides
>> support
>> for calling submit methods, etc. with the HTML document.
>>
>> This is all from memory and it's been a while, but start by adding a
>> reference in your project to the MSHTML lib, then you should be able
>> to
>> suss
>> it out from there.
>>
>> HTH
>> Sam
>>
>> "benc" <be**@discussions.microsoft.com> wrote in message
>> news:0A**********************************@microsof t.com...
>> > Hi
>> > Can some good soul help on this. I need to call jscript functions
>> > from
>> > C#.
>> > I have hosted a web control and displayed an html page successfully,
>> > but
>> > just can't find a way to call jscript functions or set some var in
>> > the
>> > html.
>> > There are some sample code in C++ using IDispatch but these are
>> > beyond me. Looked at Tim Anderson's work on HTMLEditor but couldn't
>> > find
>> > any
>> > example on calling jscript function. Read somewhere that the browser
>> > control
>> > putproperty does not work for embed control.
>> >
>> > Any help or sample code much appreciated.
>> >
>> > regards
>> > benc
>> > QMatrix
>> >
>> >
>>
>>
>>


Nov 16 '05 #6

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

Similar topics

3
by: Jon-Paul Dobson | last post by:
Hi, We have an applet that implements the MouseListener interface but when trying to add the applet to the glasspane of another applet a classcastexception is thrown. This all seemed to work...
3
by: crispy | last post by:
Hello group, I'm again having trouble putting ASP records INSIDE html link. Here's the string I put inside Access field: No room number specified (<a...
1
by: Venkat | last post by:
Hi All, I am not able to access a dll function from a remote script using ActiveXobject when an output parameter is used, but i could able to access the same when no output parameter is used....
3
by: Kim Forbes | last post by:
Hello all, I have simple function that I call from an alert box alert(testScore); It works fine. Unfortunately, I do not like the sound and Exclamation point icon that appears. I'd like a...
3
by: Charles A. Lackman | last post by:
Hello, I wrote a jscript function within the HTML window of my webpage and would like to call it from inside the ASPX code-behind page. Any suggestions? or I would like to cause an alert box...
4
by: Zeebra3 | last post by:
Here goes: I have a web form with several asp:dropdownlists, with which, when selection is changed I want to fire an event defined in some clientside js. The content of the clientside code is...
5
by: Earl Teigrob | last post by:
I am creating an application where I would like to give web designers the ablity to create a static html page and dyanamically load it into my application(exactly like loading a user control into a...
7
by: David Schwartz | last post by:
Does anyone know how I can call a function in a VB.NET DLL from Java script code? Thanks.
6
by: Adrian | last post by:
Hi I want to write a simple DLL in C# that I can call from a local html page using JavaScript. I'm looking for a very simple example! The sort of think I'm looking for is from JS to call the DLL...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.