Given the following C# code:
public object CallJavaScriptFunction(string functionName, params object[] args)
{
object script = Document.Script;
var result = script.GetType().InvokeMember(functionName, BindingFlags.InvokeMethod, null, script, args);
return result;
}
And the following client-side JavaScript block:
function someFunction() {
alert('This is only a test!');
}
var someObj = {
someMethod: function() {
alert('This is another test!');
}
}
The following server-side block executes successfully:
CallJavaScriptFunction("someFunction");
But this will throw a DISP_E_UNKNOWNNAME:
CallJavaScriptFunction("someOBj.someMethod");
Obviously I'm doing something wrong here - probably there is another way of calling InvokeMember
on JavaScript instance methods, but I was not able to find out how.
Any thoughts? Any help will be appreciated.