Bug Report B132082
Visible to All Users

Disabling an ASPxButton inside it's Client Side Click Event stops the Postback.

created 16 years ago

When you have client side script on the button to Disable the button, it prevents the buttons Click Event from being fired.
Steps to Reproduce:
See Attached Project
Actual Results:
Button is Disabled, but the Postback is canceled.
Expected Results:
Button should be disabled, and the Postback should still happen.

Answers approved by DevExpress Support

created 16 years ago (modified 13 years ago)

Hi!
This behavior is by design. We suggest that you use UpdatePanel's client-side events to enable/disable your ASPxButton.
The following code will help you:
ASPX:

ASPx
<asp:ScriptManager id="ScriptManager1" runat="server"> </asp:ScriptManager> <script type="text/javascript" language="javascript"> Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); function BeginRequestHandler(sender, args) { ASPxButton1.SetEnabled(false); } function EndRequestHandler(sender, args) { ASPxButton1.SetEnabled(true); } </script> <asp:UpdatePanel id="UpdatePanel1" runat="server"> <ContentTemplate> <dxe:ASPxButton ID="ASPxButton1" runat="server" ClientInstanceName="ASPxButton1" Text="ASPxButton" OnClick="ASPxButton1_Click"> </dxe:ASPxButton> <dxe:ASPxLabel ID="ASPxLabel1" runat="server" Text="ASPxLabel"> </dxe:ASPxLabel> </ContentTemplate> </asp:UpdatePanel>

CS:

C#
protected void ASPxButton1_Click(object sender, EventArgs e) { ASPxLabel1.Text = "Callback"; System.Threading.Thread.Sleep(2000); }

This approach is more robust than using the client SetEnabled function when handling the client-side OnClick event.
Thanks,
Andrew R

    Show previous comments (1)
    DevExpress Support Team 16 years ago

      Hi Brien,
      This ASPxButton behavior was designed to prevent a disabled button from doing a postback when it is being clicked or the DoClick client-side method is called.
      Please explain your scenario and requirements in greater detail. We'll do our best to find a solution.
      Thanks,
      Andrew R

        I have a donation page, that at the end of the process, the user clicks the "Complete Donation" button. I want to disable that button so they cannot click it a second time, which would cause their CC to be charged twice.

        DevExpress Support Team 16 years ago

          Hi Brien,
          Thank you for the additional information. However, it's not quite clear what difficulties you are experiencing when implementing this functionality.
          Could you please post here a small sample project demonstrating the problem? We'll research it and provide you with a possible solution.
          Thanks,
          Andrew R

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.