This example demonstrates how to create a button and disable its client-side functionality after the first click.
Follow the steps below:
-
Create a button and handle its client-side Click event. In the handler, do the following:
- Call the button's SetEnabled method to disable its functionality on the client.
- Send a postback to the server to prevent subsequent clicks.
<dx:ASPxButton runat="server" ID="btnPurchase" ClientInstanceName="btnPurchase" OnClick="btnPurchase_Click" Text="Complete Purchase" AutoPostBack="False" ClientEnabled="True"> <ClientSideEvents Click="OnClick" /> </dx:ASPxButton>
function OnClick(s,e){ s.SetText('Purchased'); s.SetEnabled(false); __doPostBack(s.name); }
-
After you call the
SetEnabled
method to disable a button, the control does not pass its disabled state to the server on a postback. In this case, you should handle the button's server-side Click event and set the ClientEnabled property tofalse
.protected void btnPurchase_Click(object sender, EventArgs e) { btnPurchase.Text = "Purchased"; btnPurchase.ClientEnabled = false; }
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
(you will be redirected to DevExpress.com to submit your response)