This topic is locked
[SOLVED]

 JavaScript Onload

10/12/2015 6:42:38 PM
ASPRunner.NET General questions
jadach authorDevClub member

I am trying to disable the edit button on the view page if the field RecordComplete is True.
This is not working for me. Are there any JavaScript experts who can help me out. It would be appreciated.
This snippet is in the View page JavaScript Onload event and is being ignored.
var ctrl = Runner.getControl(pageid, 'RecordComplete');

var id = "editPageButton";

var button = $("[id^=" + id + "]");

if(ctrl.getValue() == '1'){

Runner.addDisabledClass(button);

}

admin 10/13/2015

The code that disables the button is correct, I guess it's just not getting triggered. Probably control's value is not 1. If this is a checkbox its value can be 'on'.
Here is the fastest way to figure this out:

var ctrl = Runner.getControl(pageid, 'RecordComplete');

var id = "editPageButton";

var button = $("[id^=" + id + "]");

alert(ctrl.getValue());

if(ctrl.getValue() == '1'){

Runner.addDisabledClass(button);

}


This will print control value on popup box and can point you in the right direction.

jadach authorDevClub member 10/13/2015

Thanks for the help, but no pop up box appeared. And it is a checkbox, so I changed to 'on', still nothing.
Here is what I used:
var ctrl = Runner.getControl(pageid, 'RecordComplete');

var id = "editPageButton1";

var button = $("[id^=" + id + "]");

alert(ctrl.getValue());

if(ctrl.getValue() == 'on'){

Runner.addDisabledClass(button);

}
I got editPageButton1 by inspecting the element in FireFox. Maybe that's not right?

admin 10/15/2015

Alert popup should appear in any case. Something is not right here i.e. some sort of Javascript error is happening. You can check for Javascript errors if any using technique descried in this article:

http://xlinesoft.com/asprunnernet/docs/troubleshooting_javascript_errors.htm
If this doesn't help you can publish your application to Demo Account and open a ticket at http://xlinesoft.com/dss/support.asp sending the URL where we can see and troubleshoot this issue. 'Demo Account' button can be found on the last screen in the software.

jadach authorDevClub member 10/15/2015

I tried what you said and the error says ctrl.getvalue is not a function. I uploaded to demo and will put in a ticket. Thanks

jadach authorDevClub member 10/16/2015

This is solved.

Just in case someone else needs to know, here is how you do it when dealing with the view page.
Before display

pageObject.setProxyValue("RecordComplete", values["RecordComplete"]);
JavaScript Onload

var id = "editPageButton1";

var button = $("[id^=" + id + "]");

if (proxy['RecordComplete']==1){

Runner.addDisabledClass(button);

}