SharePoint Dragons

Nikander & Margriet on SharePoint

Disable ASP.NET button after click

The combination of the properties OnClientClick and UseSubmitBehavior prevent a button from being clicked twice before completed.

The following makes sure the button can’t be clicked twice:

OnClientClick=”javascript:this.disabled=’disabled'”

But, this also means the ASP.NET click event won’t happen!!! In order to do so you need to set the following:

UseSubmitBehavior=”False”

Setting this property to true bypasses the client browser’s submit mechanism in favor of the ASP.NET postback mechanism. Setting this leads to the insertion of some client-side script to the page th post the form to the server. Here’s a complete example that can be included in an .aspx page:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: