Reputation: 51064
How could I best implement the following scenario? I have a "Next Period..." button which allows the user to close the current accounting period and advance the current period. I would like to do a server side rights check on the first click of the button, and give the user an alert if they don't have the rights. If the user has rights, I want to present them with a confirmation dialogue, to confirm that they really want to advance the period.
Our standards prevent me from disabling the button if the user doesn't have rights, as the stipulate all functions should always be available, but provide appropriate feedback if they cannot execute.
If it was only the rights check, I could do the callback event, check rights, and return a script to show the user an alert, and if I wanted the confirmation before the rights check, I could show a confirm in the OnClientClick for the button, but I want the rights check before the confirmation.
Upvotes: 0
Views: 178
Reputation: 5511
If you know whether or not they have the rights when first executing the page, you can have the button return a javascript alert "You can't do that" instead of having it runing the server-side script.
That way the button is still enabled, but you don't do any unnecessary call to the server.
Upvotes: 3