The scenario: Disabled the button after user’s click event. Prevent user from clicking it several times.
The problem: If the button is disabled, the server side event handler is not fired.
The solution: Set the property UseSubmitBehavior to false.
Explanations:
Here is the working code of how to have disabled button after it is clicked:
<asp:Button ID="Button1" runat="server" Text="Do
Postback" UseSubmitBehavior="false" OnClick="Button1_Click" OnClientClick="Validate(this)" />
function Validate(thisObj)
{
thisObj.disabled = true;
return true;
}
If you don't set the property UseSubmitBehavior your code in the handler Button1_Click won’t fire. I spend several hours in debugging it. Hope this save time to somebody.
Comments
Post a Comment