tags:

views:

61

answers:

1

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.

+3  A: 

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.

Luk
Ah yes, I'd just implemented that just before I read your answer. I render out a flag indicating the rights into a script check on the button. Thanks.
ProfK
Always happy to help :) Don't forget that users may not have javascript enabled (maliciously or not), so don't assume that all users entering the function can perform the operation!
Luk
Fortunately having JavaScript enabled is a core requirement of the application. It makes extreme use of JavaScript. In fact, we're just finishing of porting it to use the extJS library.
ProfK