Last post Apr 22, 2009 11:14 AM by pkpjpm
Aug 17, 2007 02:35 PM|gdogg|LINK
event is fired twice, and it doesnt happen all the time either. I have noticed that most of the people it happens to are from places like Nigeria, India, etc, and only one from illinois. I am completely baffled. So I guess my question is: Could a slow
connection cause the double postback? What scenarios could cause such behavior given that you have 1 update panel, a button, and a textbox inside the updatepanel on the page?
I am shooting in the dark and any ideas you guys could throw out there would help. Thanks.
Aug 17, 2007 03:11 PM|gt1329a|LINK
Are you absolutely sure they aren't double clicking? You'd be amazed how many people double click things like buttons and links, because they don't know better and it works from their perspective.
Also, if you think connection speed may be a factor, it would make sense that slower response times would increase impatient second clicks, since there's no visible indication that something's happening with a partial postback.
You could try disabling the button in a BeginRequest handler, similar to what I do here:
See if that stops the double submits.
Aug 17, 2007 05:45 PM|gdogg|LINK
Thanks for the suggestion I will try those. The reason I dont think its a double click is because I have tried double clicking. I timestamp when the event is fired. I rigged it up in the buttons click event to return immediately if it has been less than
5 seconds and the contents of the textbox are the same as the contents I am currently processing. Sure enough I would get a double and sometimes a tripple post each 5 seconds apart.
Aug 17, 2007 06:16 PM|gt1329a|LINK
Aug 17, 2007 07:33 PM|rpack79|LINK
I had the same problem. I noticed that at the end of Protected Sub Page_Load.... Me.Load was listed twice. I dont know why it was there, but it was.
Aug 18, 2007 12:37 AM|Dested|LINK
This happens to me when I dynamically create a clickable control such as a button or linkbutton. The only thing I've found I can do about this is manually capture the click event by checking the Request["__EVENTNAME"] or Request["__EVENTARGUMENT"] . I usually
end up simulating the __doPostBack(name, argument) with my own values. Its unfortunate and alot of extra code, but it will work.
Aug 31, 2007 09:17 AM|ScottLloyd|LINK
Exiting news for all having double postback trouble!
Double postbacks are usually caused by one of two things:
1) bad markup in the page. run your rendered page through a validator.
along the same lines, since this is often experienced by custom control developers you should override the TagKey property and return a Div, as the default is Span and if your control renders divs, tables, etc... These are invalid inside of span tags.
2) if you are developing a custom control and have registered your postback using something like this:
+= "; return false;";
because your control is hosted in a server side form you get a postback from your script calling __doPostback in the onclick and also a postback from the <form> tag's submit handler or whatever calling __doPostback. Returning false from your
onclick method will tell the form you don't want it to process the event so you get only the postback you really want.
Sep 01, 2007 09:15 AM|Dested|LINK
Thank you for this.
Jun 30, 2008 03:07 PM|levidad|LINK
I'm currently having a problem with control state, and I think this may have something to do with the
Double Postback I get.
I started a new thread to try to solve this, and one of my conclusions is that the double postback thing started to happen from the point I added an ImageButton to the page, without any event handlers, cliet scripts or anything. This is odd, but this is
not the first time I have problems with the ImageButton.
You may wan't to track my thread:
Apr 22, 2009 11:14 AM|pkpjpm|LINK
Here's another variation of this problem and a solution. I am using button controls as part of a WebControl with a postback handler. I forgot that button controls use submit as their default type attribute. So when I registered a postback script, I got
both the postback OnClick and the form submission. This is similar to the OnClientClick issue. To solve it, I change the type attribute to button, as follows:
In this particular case, the bad behavior was occurring in IE8 but not in Firefox. Once I changed the type attrbute the code worked fine in all browsers.