This topic is locked
[SOLVED]

Difficulty in selecting Custom Button html element on an Edit Page in Javascript

5/14/2025 4:17:17 PM
ASPRunner.NET General questions
J
jMullally author

I am running the latest ASPRUNNER.NET 10.91.

The asprunner.net documention indicates to use pageObj.findItem(itemid) where itemid is defined for the Custom Button in the Designer and that returns the control for the span surroundng the button as can be seen in the attached page inspection
img alt

Retrieving the span around the custom button does not help me when I want to change the button's css properties. The only work around I found was to operate on the button's id that I found from page inspection - which in this case is 'New_Button3_8' and then go back to the javascript and make adjustments accordingly. The following accomplishes my goal. But I am not satisfied with the process as when I have changed the page in the designer, the Custom button's ID did change.

var ship_btn = $("a[id^='New_Button3_8']"); // Gets the Custom Button element. Had to find the Custom Button's id by page inspection.
var ship_btn2 = pageObj.findItem('ship_btn'); // Gets the span surrounding the Custom Button element - of no help

ship_btn.css('width', 270); // These 4 lines syccessfully set the Custom button's properties
ship_btn('text','Not Ready to Ship');
ship_btn.css('background', 'lightgray');
ship_btn.css('color', 'gray');

I assume many people have run into this issue. I am asking if anyone found a better solution in 10.91. It does not matter to me if the solution is in Javascript or C# (server side). Thank you.

Admin 5/14/2025

You are doing it wrong. We have an API that allows you to quickly access jQuery object that represents the button:
https://xlinesoft.com/asprunnernet/docs/getitembutton(itemid_recordid).htm