C# to JavaScript Communication - Function Calls

Add-in Express™ Support Service
That's what is more important than anything else

C# to JavaScript Communication - Function Calls
Running functions between JavaScript and C# 
Rabbit




Posts: 21
Joined: 2011-02-04
If I wanted to run a JavaScript function from C# I can use window.execScript but..

How can I call a C# function from within JavaScript please?

e.g.
<sc ript type="text/javascript" language="JavaScript">
control.runCsharpGet(this, "hello");
</script>
Posted 08 Feb, 2011 09:26:13 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Rabbit,

Please have a look at the How to run and replace a script (JavaScript, JScript or VBScript) on an HTML page in IE 6 or 7 sample add-in project.
.NET, Extended MAPI, Windows Phone & RT
Posted 08 Feb, 2011 09:30:19 Top
Rabbit




Posts: 21
Joined: 2011-02-04
Thank you for your reply,

I can see the C# accessing the page and modifying the JS in the example, but I can't seem to see JavaScript directly calling/running any C# functions?

I have a C# function that saves a string it is passed in a text file, and another that gets the saved value from the text file, and I need to run these two C# functions from the JavaScript itself (for long term data storage).

I cant seem to find a command for this..

(I am working on a project without a toolbar or menu interaction).
Posted 08 Feb, 2011 09:59:38 Top
Rabbit




Posts: 21
Joined: 2011-02-04
Edit: I am hoping to test the add-on I have been developing on an IE6 and IE7 machine once I can get this issue resolved, but I still can't find any leads on how to run a C# function from within JavaScript.

Please can someone help me urgently, I am quite stuck at the moment.
Posted 08 Feb, 2011 11:13:31 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Hi Rabbit,

Please look at the following example:
http://www.add-in-express.com/files/projects_pub/access_bho_from_js.zip
Posted 09 Feb, 2011 10:35:32 Top
Rabbit




Posts: 21
Joined: 2011-02-04
That was exactly what I was looking for.

Thank you ever so much!
Posted 09 Feb, 2011 12:41:20 Top