Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy button onclick fires multiple times?
    text
    copied!<p>I have a ajaxmodalpop and it has some controlslike the below; The problem is whenever I press "Enter" key on textbox it sets focus to the button (that is correct) but <b>If I press five or 6 times(or manytimes) "Enter key" very quickly then the button fires as many times as I pressed enter key.</b> Although I have a validation function on client click of the button and it must not(Even can't go through from validation function if textbox values are cleared) pass that function for every second time. Because I clear the textbox value from server side.</p> <p><b>It is very urgent dear Experts</B></p> <pre><code>&lt;asp:TextBox ID="txtPurpose" runat="server" TabIndex="4" Width="558px" Style="text-transform: uppercase; overflow: hidden" CssClass="textleftWithBorder" ClientIDMode="Static" onkeydown="ConvertEnterToTab(event)"&gt;/asp:TextBox&gt; &lt;asp:Button runat="server" ID="btnSubmitNAdd" TabIndex="5" Text="Submit &amp; Add" ClientIDMode="Static" UseSubmitBehavior="true" onkeydown="HandleLeftRightArrow(event,'btnClose','btnSubmitAndClose')" OnClick="btnSubmitNAdd_Click" OnClientClick="return Validate()" /&gt; </code></pre> <p>and functions are;</p> <pre><code> function ConvertEnterToTab(e) { var keyCode = e.keyCode || e.htmlEvent.keyCode; if (keyCode === 13) { var nextElement = document.getElementById("btnSubmitNAdd"); if (nextElement != undefined) { nextElement.focus(); e.cancelBubble = true; e.returnValue = false; return false; } } } function Validate() { if (ValueOf("txtCustomerName") != _CustomerResetText) { return true; } else { return false; } } function HandleLeftRightArrow(event, leftControl, rightControl) { var code = (event.keyCode ? event.keyCode : event.which); if (code == 39) { if (document.getElementById(leftControl).disabled == false) SetControlFocus(rightControl); } else if (code == 37) { if (document.getElementById(rightControl).disabled == false) SetControlFocus(leftControl); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload