Geeks With Blogs
Fórmulas e Cenas Object Reference Not Set to an Instance of an Object
A few days ago I got an error report to fix. Some web application that I now maintain was inserting duplicate records.

After a quick look it became obvious that the users where double clicking the submit button and that made the page post twice and so a duplicate record would appear.

A quick fix dor this problem using javascript:

<script language="javascript" type="text/javascript">
        var haveSubmitted=false;
        function FirstSubmitOnly() {
            if (haveSubmitted)
                return false;

            haveSubmitted = true;
            return true;
        }
    </script>


And at the form tag just invoke the function <form id="form1" runat="server" onsubmit="return FirstSubmitOnly();">



Enjoy :) Posted on Wednesday, August 19, 2009 12:26 PM Geral , Asp.Net | Back to top


Comments on this post: Prevent Double Post

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Sglima | Powered by: GeeksWithBlogs.net