Ticket T634993
Visible to All Users

ASPxButton -The ASPxButton.Click event fires twice after a click

created 7 years ago (modified 7 years ago)

The DevExpress template creates a web app including a Login.aspx and Register.aspx.  I have noticed the click code for btnLogin as well as btnCreate runs twice every time the buttons are pressed.  This causes an error when creating a user because it tries to create the same user twice.  After a great deal of experimenting, I have found a workaround by turning off the "UseSubmitBehavior" as follows:

ASPx
<dx:ASPxButton ID="btnLogin" runat="server" Text="Log In" ValidationGroup="LoginUserValidationGroup" OnClick="btnLogin_Click" UseSubmitBehavior="false"> </dx:ASPxButton> <dx:ASPxButton ID="btnCreateUser" runat="server" Text="Create User" ValidationGroup="RegisterUserValidationGroup" OnClick="btnCreateUser_Click" UseSubmitBehavior="false"> </dx:ASPxButton>

What is causing the click event to run twice?  Is it correct to turn off the "UseSubmitBehavior"?

Show previous comments (4)
DevExpress Support Team 7 years ago

    I tested your project using the "Remove Session Objects" button with the same result - the ASPxButton.Click event fires just once. Please take a look at the new video. If I missed something in my testing scenario, please describe steps to reproduce the issue in greater detail. Also, please check your project in a different web browser or on another developer machine. Another suggestion is to make sure that ASPxButton is not clicked twice, for instance using a double-click. In this case, a page sends two requests to the server, so the ASPxButton.Click event may fire twice.

    LM LM
    Larry McIntosh 7 years ago

      I don't understand why your IIS is behaving differently.  It happens on my development computers and at my client sites.

      DevExpress Support Team 7 years ago

        It is difficult to find the cause of the issue without debugging it. Note that the ASPxButton.UseSubmitBehavior property is set to "True" by default, so ASPxButton uses a client browser's submit mechanism. If you specify false, the ASP.NET postback mechanism is used. Also, please refer to the How to prevent double clicking or multiple Form submission after the ASP.Net Button is clicked? article, which may help you resolve the issue.

        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.