[SOLVED] Calling Javascript on Button click event

Answered
0
0

Dear Team,

I have JavaScript file my_js.js which has Helloworld() function.

The function will return the alert saying “Helloworld”

Please let me know, how can i import this .js file in my project to call the Helloworld function on button click event.

 

Thanks in advance.

P Vishal

  • You must to post comments
Best Answer
0
0

Hi Vishal,

there are a couple of options in Wisej.
Here are a few:

Please refer to https://wisej.com/docs/html/JavaScript.htm

  • Add your javascript file to the project and set the build action to “Embedded Resource”
  • Modify AssemblyInfo.cs and uncomment the line with …WisejResources…

Then you can either attach to the server side click event and call your code on the client:

jsa

Or use the JavaScript extender (drop it on the container of your button) and edit the JavaScriptEvents property:

jsb

Please note that our upcoming Wisej 2 release does not need the JavaScript extender for this anymore.
All components have those 3 javascript properties by default allowing a very tight and easy integration
of server and client code.

Hope that helps.

Best regards
Frank

Attachment
  • You must to post comments
0
0

Hi Vishal,

there are a couple of points that prevent your sample from working:

  1. the resource file names in VB.NET need to be prefixed with Resources. or Platform. in order to be bundled by Wisej.
    For C# this is deducted from the folder name but for VB.NET it´s ignored. So please rename for file to Resources.JavaScript1.js
  2. the call in your application should be Application.Call(“window.show”, “”) instead. No need to add (); to it since the function parameters
    are to be placed in the second parameter of Application.Call

A different approach to having Wisej bundle the resources can be to included it in default.html with simple html <include src …. directives

Finally you could also use the JavaScript extender and reference your JavaScript file there.

Hope that helps.

Best regards
Frank

  • You must to post comments
0
0

Dear Team,

I have tried first case with resources adding, but its not working.

I have attached the project here.

Please let me know where is the issue.

 

Thanking you,

P Vishal

Attachment
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.