Skip to main content

Prevent multiple postbacks in SharePoint 2013


The scenario:  Disabled the button after user’s click event. Prevent user from clicking it several times.

The problem: If the button is disabled, the server side event handler is not fired.

The solution: Set the property UseSubmitBehavior to false.

Explanations: 

Here is the working code of how to have disabled button after it is clicked:


<asp:Button ID="Button1" runat="server" Text="Do Postback" UseSubmitBehavior="false"  OnClick="Button1_Click" OnClientClick="Validate(this)"  />


       function Validate(thisObj)
       {
           thisObj.disabled = true;
           return true;
       }


If you don't set the property UseSubmitBehavior your code in the handler Button1_Click won’t fire. I spend several hours in debugging it. Hope this save time to somebody.




Comments

Popular posts from this blog

ClientPeoplePicker in SharePoint 2013

Start using SharePoint 2013 I noticed that the way for selecting people or groups is changed. The new way is simple – just ‘Enter name or email address’ without any icons for ‘Check Names’ or ‘Browse’. I guess that the PeoplePicker is changed but NO. PeoplePicker sitll has the same functionality as before. There is a new control called ClientPeoplePicker . How to use it: 1. Add this references <% @ Register TagPrefix ="wssawc" Namespace ="Microsoft.SharePoint.WebControls" Assembly ="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 2. Add the following control declaration       < wssawc : ClientPeoplePicker          Required ="true"          ValidationEnabled ="true"          ID ="peoplePicker"          runat ="server"   ...

Application User form is missing in Dynamics 365

The option to use Server-to-Server authentication in Dynamics 365 is an important technical approach. It consists of two elements:  1. Azure AD application  2. Dynamics 365 Application user created with the Azure AD application's ID There are many posts about this concept, please do a search and learn it. What I want to show you here is how to solve the problem - Application User form is missing: In order to create an Application user through the web interface, you need to go to: Settings -> Security -> Users -> New: If everything is OK you will see the User's new form and the "Application User" option will be available: If you don't see it, this mean that the form is not Active and you need to active it.  Here are the steps: Step 1: Navigate to the Customise the System: Step 2: Select User entity and choose Forms: Step 3: Select the filter "All Forms" Step 4: Select "Application User" form...

SharePoint User Group Bulgaria

In the past year I invested my free time in activities related to the SharePoint User Group Bulgaria. This is the reason why I stopped writing in this blog. Please start following this new place  www.sugbg.com . I promise you that you will find there truly valuable content.