Calling a non-static method in a Form from javascript.


Hello Support.

I have been trying to call a method in my form’s class from javascript but it never gets called, the javascript just quits at the call. I have marked the method with [WebMethod]. My javascript is in an Eval statement. If I make the method static then the call is successful and the remaining javascript commands are executed. When it is not static the javascript just stops executing at the command that calls the method. In the Documentation page titled ‘JavaScript Object Model’ it has an example of javascript calling a non-static method but it doesn’t work for me – what could I be missing ?

My method, which is in class inheriting Form:

public void MakeGroupBoxVisible()

And my javascript:

this.Eval(@”alert(‘111’); ” +

App.EntryForm.MakeGroupBoxVisible(); ” +


(I see the ‘111’ alert but not the ‘222’).


On a similar topic I was originally trying to change the visibility of a groupbox in my form from JavaScript. I can set the content of a textbox with javascript such as:


but I can’t work out the syntax to change the visibility of a groupbox that I have in the form. The groupbox is directly on the form, not contained within another element. I have tried things like:‘visibility’, ‘visible’);

and = ‘visible’;

But no luck. Any ideas ?

(I am aware that setting visibility etc. would normally be done in C# but I have one page that requires javascript so I am trying to handle everything within javascript just for this page).

Thank you


  • You must to post comments

Hi Andrew,

I have tried calling the WebMethod (non static) in a simple sample and it works just fine.

For showing/hiding the GroupBox you could simple use the show() / hide () functions.

Do you get any errors in the Console ? Any chance to share a sample for both scenarios to see what could be different in your code ?

Thanks in advance.

Best regards

  • Andrew Pearce
    Hello Frank. Thank you for helping me with this problem. I set up a test solution which I could send to you and… it worked properly !! But my actual application still didn’t work :-( I kept investigating and found that if I added a parameterless constructor to my form in my actual application it would also work (even if I wasn’t using the parameterless constructor to create the form). In my test solution I found that if I made the only constructor of the form require a parameter then my test solution did not work ie the [WebMethod] method was not called, in fact it gave an error message saying it could not find the method on the object. My actual application gave no error. I found that calling the [WebMethod] method directly from javascript produced the error but calling it from a XMLHttpRequest onreadystatechange callback (as my actual application does) gives no error message, it just silently fails. With this new knowledge I can get my app working so am happy in that regard. If you want to follow this up you can download my small test solution from!Ar2BK2yOZisyvVuJGpQ7hn1JYuzt It has some explanation on the desktop that opens when you run the application. Andrew
  • Frank (ITG)
    Thanks Andrew for taking the time to set up a test case and for explaining the steps to resolve this. I will check the code and see if it´s something we need to fix/improve in Wisej. Best regards, Frank
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.