Fórmulas e Cenas

Object Reference Not Set to Instance of an Object

  Home  |   Contact  |   Syndication    |   Login
  39 Posts | 0 Stories | 6 Comments | 0 Trackbacks

News

Archives

Post Categories

Links

Wednesday, August 19, 2009 #

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 :)
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati