title: Asp.net OnClick event is not triggering after ajax is called too many times.
body: <p>I am working on dashboard and using <a href="https://troolee.github.io/gridstack.js/" rel="nofollow noreferrer">gridStack</a>.I am updating database with ajax. The data is x,y positions of html elements(some divs on page). Here is my javascript code: </p>
  
  <pre><code>// The "dragstop" fucntion is called when I stop dragging the &lt;div&gt; element.
  
       $(".grid-stack").on("dragstop", function () {
          setTimeout(function () {
              saveAllWidgets();
          }, 100);
      });
  
  
  function saveAllWidgets() {
      var serializedData = _.map($('.grid-stack &gt; .grid-stack-item:visible'), function (el) {
          el = $(el);
          var id = el.attr('id');
          var node = el.data('_gridstack_node');
          return {
              x: node.x,
              y: node.y,
              width: node.width,
              height: node.height,
              id: id
          };
      });
  
      var jsonString = JSON.stringify(serializedData);
      try {
          $.ajax({
              type: "POST",
              url: '/STARCOHttpHandlers/UpdateDashboardWidget.ashx',
              contentType: "application/json; charset=utf-8",
              data: jsonString,
              dataType: "json",
              success: function(data){
      //I am always getting the success response and I checked DB is also updating
                  console.log(data); 
              },                 
              error: function(){
                  console.log("some error occoured db is not updated!!");
              }
          });
      } catch (e) {
          alert(e);
      }
  }
  </code></pre>
  
  <p>Now the problem is if I call the above function too frequently (too many drag/drop). And then click the below mentioned asp.net button, the page gets reload but the OnClick events doesnot triggered (also in debug mode the codes is not called at all). After Page gets reload and I click the second time on this button then the onClick event gets triggered.</p>
  
  <pre><code>&lt;asp:Button runat="server" ID="btnUndoChanges" CssClass="btn" Text="Undo all changes" OnClick="btnUndoChanges_OnClick"/&gt;
  
   protected void btnUndoChanges_OnClick(object sender, EventArgs e)
          {
  
              return;
          }
  </code></pre>
  
  <p>I don't have any idea why its behaving like this. Could it be related to the IIS security or viewstate ? </p>