all groups > dotnet jscript > january 2007 >
You're in the

dotnet jscript

group:

communication between JScript and C#


communication between JScript and C# bowser
1/11/2007 3:13:43 AM
dotnet jscript:
Hello,
I have a problem of communication between JScript and C#. I must say
that I'm new to both.
In a JS file I have to call a C# function.
In particular I have:

public function Eval(expr : String) : String
{
return eval(expr);
}

And I want to call:

Eval("MyNS.myFunction()");

where myFunction is declared in a C# file, under the namespace MyNS,
and returns a string.

Is it possible to do such a thing without to consider COM objects
(which I've heard to be used in similar problems)?


Note that the .js file is generated dinamically by a CodeDomProvider in
C#.
It is compiled by adding the reference of the .exe file, which contains
myfunction():
parameters.ReferencedAssemblies.Add("MyApp.exe");
So the call Eval("MyNS.myFunction()"); will be done with Reflection


One more question: is there another way to use the jscript function
eval in C#? Maybe compiling a .js module (not dinamically and not using
reflection) that can be used by a C# module?

Thank you.

Alessandro
Re: communication between JScript and C# Brian Williams
1/15/2007 8:59:46 AM
You will need to use AJAX, ASP.Net AJAX, or Remote Scripting to call server
methods from client side.
I would use ASP.Net AJAX.

http://ajax.asp.net/ (ASP.Net AJAX)
http://www.codeproject.com/aspnet/AlvaroRemoteScripting.asp
http://developers.sun.com/ajax/index.jsp?cid=59754

Regards,
Brian K. Williams

[quoted text, click to view]

AddThis Social Bookmark Button