Block delete link with JS message (list page) (v2024)

I’m upgrading a project from v2020 to v2024. This code in ListOptions_Rendering() used to work, but now I get and ‘Invalid URL’ error message when I click the delete link:

$this->DeleteUrl = "javascript:alert('You are not allowed to delete this record.');";

How can I implement this in v2024?

Thanks.

You better use TablePermission_Loaded server event to set canDelete(false) instead.

Yes, but that would remove all the delete buttons and, in this case, I want to keep the buttons either to allow deleting or to deny and convey a message. My example is simplistic but, in reality, I want to inform the user of one of several reasons why the deletion attempt is being denied.

I can capture the click event client-side, but for that I’d need a unique id to each delete button. Is there any way to add that or another alternative to single them out?

You may try enable Use buttons as links and/or Use button dropdown for links.

I get an ‘Invalid URL’ error just the same.