How To Prevent Multiple Form Submission

Dear Members,

Details about application:

I have a CGridView with a checkbox column. A cancel (ajax submit) button out of gridview. Now the user can select any row and press cancel button to call a controller’s action.

Problem/Issue:

The issue is that, if user presses cancel button multiple times (repeatedly) before the first request has been completed, the corresponding action is also called multiple times, causing invalid entries.

Desirable Solutions:

  1. Font End: To prevent users from pressing a button which has been previously pressed and previous request has not been completed yet.

  2. Back End: Code the controller’s action to be aware of this kind of multiple calls, and ignore if previous call was not completed.

Waiting for your replies please.

I would hide the cancel button after first click and show a loading indicator or something else instead. If the action has finished show the cancel button again.

Yes, front end solution is simple. But i am more interested in back end (controller action) solution, which is also more concerned with this forum as well.

Ok, on server side you can write something to session to indicate if the cancel operation has clicked. So if the user clicks again you check the session if cancel click is allowed. If not inform the user or do nothing…

Oh Yes, you are right i should think it in that way. Thank you.