I am trying to prevent users from double-clicking the submit button for the page I am updating. The problem is that in order to check whether the user needs to make any updates, before we can move on, you need to perform a server-side check. Currently, I have the following code for my post for my form.
<asp:Button ID="SubmitPayment" runat="server" OnClientClick="this.disabled='true';" UseSubmitBehavior="false" OnClick="SubmitPayment_Click" Text="Submit" />
If this becomes a problem, the page fails verification. In this case, everything I tried to enable failed. It is difficult for them to resend the corrected information with the send button disabled. At the end of my test, I tried both of the following methods to enable it again.
SubmitPayment.Enabled = true;
SubmitPayment.Attributes.Add("disabled", "false);
What do I need to do to enable this control again? This is in Visual Studio 2005. Thanks in advance.
-edit- The approach I used was as follows. I added an extra bait button that was disabled, and the display css property for display was none. Then I used javascript that will hide the submit button and show the bait button in the OnClientClick event. Finally, the end of the server-side method will update the css properties on the buttons to hide them and show them later.
The code segments are as follows. Thanks again for the help
function PreventDoubleClick()
{
var sp = document.getElementById("SubmitPayment");
var db = document.getElementById("DecoyButton");
sp.style.display = "none";
db.style.display = "inline";
}
<asp:Button ID="SubmitPayment" runat="server" OnClientClick="javascript:PreventDoubleClick();" UseSubmitBehavior="false" OnClick="SubmitPayment_Click" Text="Submit" />
<asp:Button ID="DecoyButton" Enabled="false" runat="server" style="display:none;" Text="Please Wait..."/>
DecoyButton.Style.Add("display", "none");
SubmitPayment.Style.Add("display", "inline");
source
share