Running WebMethod from Javascript

Answered
0
0

I’m working with a basic proof of concept for running a webmethod from javascript.  My larger aim is to use keyboard arrows to run vb.net functions.  I am admittedly a noob on javascript but I have been pouring over the wisej documentation.  All code is in Window1.  Here’s my code:

Public Overrides Sub Update()
MyBase.Update()
If (CType(Me, IWisejComponent)).IsNew Then RunJavaScriptCode()
End Sub
Private Sub RunJavaScriptCode()
Eval(“this.hello = function()
{
window.parent.App.Window1.HelloWorld();
}
“)
End Sub
<Wisej.Core.WebMethod>
Public Sub HelloWorld()
MsgBox(“Hello, World!”)
End Sub

The sub Update calls the sub RunJavaScriptCode but the HelloWorld sub is never called.

What am I missing?

As a second test I replaced the “If” line in the sub Update with this direct call to the sub HelloWorld:

Application.Call(“HelloWorld”)

It errored “HelloWorld” is an unknown function. Perhaps here I need a different call i.e. something like WebMethod.Call or ?.  I can’t find any documentation.  It made me think the webmethod “HelloWorld” is not registered.

Thanks!

Gerry

  • You must to post comments
Best Answer
0
0

Hi Gerald,

Replace this
Eval(“this.hello = function()
{
window.parent.App.Window1.HelloWorld();
}
“)

By
Private Sub RunJavaScriptCode()
Me.Eval("App.Window1.HelloWorld();")End Sub

Take a look to a sample on attachement

Happy coding,

Kevin(ITG)

  • You must to post comments
0
0

Thanks very much!

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.