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:
[Wisej.Core.WebMethod()]
public void MakeGroupBoxVisible()
{
MessageBox.Show(“Hello”);
}
And my javascript:
this.Eval(@”alert(‘111’); ” +
App.EntryForm.MakeGroupBoxVisible(); ” +
alert(‘222’);”);
(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:
App.EntryForm.UserNameTextbox.setValue(‘Jim’);
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:
App.EntryForm.MyGroupbox.style.setAttribute(‘visibility’, ‘visible’);
and
App.EntryForm.MyGroupbox.style.visibility = ‘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
Andrew
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
Frank
Please login first to submit.