...take a close look at your code .
This comes from a case I worked on in the last couple of days: a customer reported a problem in one of his ASP.NET 2.0 pages, which is meant to perform some sort "long running" operation on the server. What puzzled me a bit (well... quite a bit, at the beginning) is the fact that after the user clicked posted the page (clicking on a submit button) and the long operation begun on the server, after about 90 seconds they noticed a new click button for the submit event was fired, thus restarting the whole "long" operation (and of course leading of all sort of problems this implies for the application's logic).
Doing some tests we found that more that the above, even if he closed the browser on the client immediately after submitting the form, after about 90 seconds they still got a second click event firing for the submit button! Of course if the browser is closed on the client, it's hard to believe that the new click and subsequent post is coming from the user...
We looked and the page source produced by the server, here is an interesting excerpt:
<input type="button" name="ctl00$ContentPlaceHolder$ButtonSubmit" value="Submit data" onclick="this.disabled=true; this.value='Please wait...'; __doPostBack('ctl00$ContentPlaceHolder$ButtonSubmit',''); __doPostBack('ctl00$ContentPlaceHolder$ButtonSubmit','')" id="ctl00_ContentPlaceHolder_ButtonSubmit" />
(note that I broke the onclick Javascript line value only for formatting purposes in this post, that was on a single line)
It is clear that ASP.NET generate that button with wrong content for the onclick event handler, note the duplicated "__doPostBack(...) call". Question is: why?
The customer sent me the click event handler method and the button declaration, which looked like the following:
<asp:Button ID="ButtonSubmit" runat="server" CausesValidation="False" Text="Submit data" OnClick="ButtonSubmit_Click" UseSubmitBehavior="false" />
(they also had AutoEventWireup="true" in their @Page directive, and this is what actually put us on the right track even if not directly involved in this problem)
The customer then reviewed more closely some of their code (unfortunately he inherited this project and did not worked directly on the code, so he didn't know all the details...), and found that in the Page_Load handler they dynamically added a Javascript call to __DoPostBack(...) using code similar to the following:
ButtonSubmit.OnClientClick = ButtonSubmit.Page.ClientScript.GetPostBackEventReference(ButtonSubmit, null);
So, now is clear that the problem was cause by both ASP.NET adding the callback handler because of UseSubmitBehavior="false" in the button declaration, and the GetPostBackEventReference(...) call in the Page_Load method; the customer was therefore able to fix the problem simply changing the button declaration to use UseSubmitBehavior="true" (which, by the way, is the default, read the MSDN reference for further details.
Cheers
I ran into the same problem, when the client clicks on the button on a grid view they will confim if they wish to delete the file. If they click ok it fires the click event for the button. Then it fires the event again for some reason i added everything using the property field and the template editor. Here is the code.
<asp:Button ID="Button1" runat="server" CommandArgument='<%# Eval("UserName") %>'
CommandName="DeleteUser" Text="Delete user" OnClientClick="return confirm('Are you sure you want to delete this User?')" />
Hi Lewis, with a simple test on my machine I can't repro the problem so I can't tell you exactly what's going on in your app, sorry; but I can suggest you to have a look at the HTML code in IE ("view source") and try to identify if there is any "duplicated" javascript code which may submit the page twice.
HTH
I have a similar issue. A vanilla aspx page: a message with a single button which is sent as an email to the client. When the button is clicked in Outlook, we get two server calls. The first, using the debugger, has all the data in it. The second is empty. Sadly it's the second one which gets rendered. The correct page processing is lost.
The calls are in different sessions - so no ViewState or Session fiddling can be employed. Trying to figure out what is triggering the second call and where it is coming from.
There is no javascript in the email page. Submit behaviour is used, and autowireup, but there are no events wired in.
David, do you actually mean OWA or the full Outlook client? Which is the correlation between the aspx page and Outlook?