I am trying to stop users from double clicking my ASPxButton.
What's happening is they click the button twice, and two post backs occur and two entries get created.
I want to disable the button after click to try prevent the problem (i realise this is not full proof, but good enough)
I managed to do this using the SendPostBack and SetEnabled on the click event.
This however breaks if the user hits enter.
The page reloads, but the button click event is not fired.
My button looks like this
ASPx<dx:ASPxButton ID="btn" OnClick="btn_Click" runat="server" Text="ASPxButton">
<ClientSideEvents Click="function(s,e){
s.SendPostBack('Click');
s.SetEnabled(false);
}"></ClientSideEvents>
</dx:ASPxButton>
My Code Behind like this
C#protected void Page_Load(object sender, EventArgs e)
{
Thread.Sleep(1000);
if(IsPostBack)
{
lbl.Text = DateTime.Now + " - Page Load Called<br/>";
}
}
protected void btn_Click(object sender, EventArgs e)
{
lbl.Text += DateTime.Now + " - Button Click Called<br/>";
}
If you click on the button with your mouse, both server side events are fired.
If you hit enter on the keyboard (even when the button is selected), btn_Click never gets fired.
Please can you help me to fix this issue so the enter key will work and disable the button
Attached is my small example of the problem