Scenario – a webpage with controls on page, button click, long running process.
Pitfalls – process may take longer than expected (not instantaneous) and the button is pressed again which may uncover undesirable side-effects.

When an engineer designs a web page to perform some type of processing, we generally don’t consider the time it will take to complete that task. During functional testing, the engineer will press a button to perform a task and just wait for the postback to occur so we can do something else. The engineer knows that the long running task takes a few moments and we will just wait on the completion.

Conversely, applications users (myself included) have very little patience and want instant results. So the user may push the button expecting instant results and it appears that nothing is happening, so we will attempt to push the button again, and again.

Recently, developers started adding controls <asp:UpdateProgress ID=”UpdateProgressControl” runat=”server” … /> to their web pages to give the user the confirmation that the task is actually doing something. Although a progress control is nice, it doesn’t prevent the user from clicking the button again.
pleasewait

Here are two separate approaches to not allow the user to click on the button multiple times prior to the process finishing.

Alternative #1 – javascript within the markup.

Results:

results1  results2

Alternative #2 – javascript added from the code behind.

Results:
results1

In conclusion, the above examples worked for me and my situation. Each situation is different and they all have other programming challenges. Developers need to take into consideration these challenges and provide the application with the best approach to solve the problem.

Like this post? Share it!