Reza on blogging [MVP]

THIS BLOG HAS MOVED TO: http://blogs.devhorizon.com/reza

Subscriptions

<February 2012>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910

News



toronto.sharepoint.camp


Navigation

Post Categories

Other Bloggers

Personal Links

Friday, July 07, 2006 - Posts

How to prevent users from multiple submissions
I have been repeatedly asked about how to prevent users from clicking submit button more than once. If you have ever faced such a problem, you would probably know that there are many ways suggested by folks to handle this, things like using two buttons, disabling submit button using JavaScript and so on. Regrettably I never did find anything that worked like they said it would and more importantly some of those methods causes your server side events not to fire. The way I deal with this issue is not just disabling the button by greying it out, but not letting the form to be posted back using the code below:
1) Put this in between the HEAD tags of your page:

<HEAD>
...
  <SCRIPT language=javascript>
     var isSubmittedFlag= false;
  </SCRIPT>
...
</HEAD>

2) Add the following java script code to the button attributes collection in  Page_Load() event of your page

btnSubmit.Attributes.Add("onclick", "BLOCKED SCRIPTif(isSubmittedFlag){alert('Your first request is still being processed');return false;}else{isSubmittedFlag=true;return true;}")

posted Friday, July 07, 2006 1:43 PM by admin with 0 Comments

Powered by Community Server, by Telligent Systems