javascript - Multiple Concurrent Postbacks when using UpdatePanels -


Here's an example app that I created to showcase my problem. This is a single ASPX page with the following:

  & lt; Form id = "form1" runat = "server" & gt; & Lt; Asp: ScriptManager runat = "server" /> & Lt; ASP: Button Run = "server" id = "btn go" text = "go" onclic = "btn go_click" /> & Lt; Asp: UpdatePanel runat = "server" & gt; & Lt; ContentTemplate & gt; & Lt; Asp: textbox runat = "server" id = "txtVal1" /> & Lt; / ContentTemplate & gt; & Lt; / ASP: UpdatePanel & gt; & Lt; / Form & gt;  

Then, in the code behind, we have the following:

  Secure zero btnGo_Click (Object Sender, EventArgs E) {Thread.Sleep (5000); Debug.lightline (string.format ("{0}: {1}", date time.Now.ToString ("HH: MM: ss.fffffff"), txtVal1.Text)); TxtVal1.Text = ""; }  

If you run it and click on the "Go" button several times you will see many debug statements on the "Output" window, showing that multiple requests were processed Are there. This opposes the document behavior of the updated panel (ie, if you make a request while doing a procedure, the requests are terminated first and a process is currently performed).

However, the issue is that I want to fix it. Clear option Javascript will be used to disable the button after the first press, but it kills me as hard work to maintain, we potentially have the same problem on many screens which can easily be broken If someone changes the name of a button

Do you have any suggestions? Maybe there is something that I can do to locate a duplicate request in Global.asax in DoubleRequest? Is there some setting or feature on UpdatePanel to prevent this from happening, or maybe something in AjaxControlToolkit will stop it?

Create a custom control that is received from the ASP button and enables the script to be disabled and itself Has not been tested but is the starting point.

  Public category SafeButton: System.Web.UI.WebControls.Button {Public SafeButton () {OnClientClick = "JavaScript is here to disable this button"; ScriptManager.RegisterStartupScript (this is true, getType (), "keyphony", "Javascript goes here to enable this button", true); }  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -