A little while ago, I messed around with ways to disable a submit button so that it didn't double post. The example I had worked ok, in that it was impossible to click the button twice, because as soon as it had been clicked, it disappeared. However, what I really wanted was to just disable the button. Unfortunately, using client script to disable the button also cancelled the post.
This came up yet again at work, and once again Carlos Aguilar had a clever answer. He discovered an interesting trick: rather than disabling the submit button immediately, you can use window.setTimeout() to set a short interval (zero seems to work) before invoking a method that disables the button. I'm assuming that the script has to "release" in order for the post to work, and using a short timeout accomplishes this.
Starting with the code from the original post, I changed the client code to this:function disableButton()
{
window.setTimeout('disableAfterTimeout()',0);
}
function disableAfterTimeout()
{
document.form1.SafeButton.disabled = true;
}
You can see the effect in this test page:
Double post (with disable)
Carlos's original example was much more clever; he uses server code to build up a list of controls that should be disabled in this way. He also noted that if the user clicks the browser's Stop button, the disabled controls stay disabled. Cure: don't do that, heh.
Update I also did some experimentation with using a GUID to track the uniqeness of each postback. See details in this post.