locked
button - click once RRS feed

  • Question

  • User-125499312 posted

    how do i force that a button gets clicked only once?

    Thursday, January 23, 2020 4:48 PM

All replies

  • User281315223 posted

    You could explicitly disable it after it's clicked, which would prevent it from being clicked again. If you are referring to Web Forms, then you could just set the triggering button to disabled within the Click event handler:

    protected void YourButton_Click(object sender, EventArgs e)
    {
        // Disable the button
        YourButton.Enabled = false;
    }

    If you are referring to client-side (e.g. Javascript), the same basic ideas apply such as setting the button to disabled:

    <asp:Button ID="YourButton" ... OnClientClick="this.disabled = true;" />

    Thursday, January 23, 2020 10:18 PM