1

I know the general guidelines to double-postbacks, but this one is driving me nuts. It's a button onclick. C#. ASP.NET 2.0. And it's intermittently posting back twice when I click it in production. Can't replicate from staging, at least on the scale I've tried so far.

The code hasn't changed since before it starting doing this, as far as I can tell, and the flow of the logic certainly doesn't call for a double-dip into the click code at random times. I'm starting to dive into network traces (there are some duplicate acks and dropped segments, to be fair) and wondering if I should nuke the Temporary ASP.NET folder.

Also eyeballing this jQuery modal popup .click(function() call that returns true. Something in the back of my Javascript brain makes me suspicious.

And this interesting bug that has to do with blank img sources.

1
  • IE, so far. The Javascript path I just recently wandered down, so I'll start hacking at others now. Chrome's up next.
    – Chris
    Apr 14, 2009 at 11:12

3 Answers 3

4

I've only seen this problem pop up when a button click calls javascript that manually calls form.submit() but does not correctly cancel the click event, and thus it posts twice.

I'm not sure but I believe that if that's the case, one postback will include ButtonID=ButtonID and one will not.

1
  • Good suggestion, I'll start looking at the click code more carefully.
    – Chris
    Apr 14, 2009 at 11:13
0

make sure you are not handling the even on other Events too, like Page load, Page Init

0

And make sure you don't cause double-postback yourself in handling onsubmit event on form tag the wrong way. Like:

function Loading() {
  $('*').css('cursor','wait'); // To change cursor while waiting for postback
  document.forms[0].submit();  // Cause postback (maybe 2nd time if already fired by Button).
}

<form id="form1" runat="server" onsubmit="Loading();">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.