title: How to call only one button click function when user press enter from Textbox in Jquery?
body: <blockquote>
    <p>I already made my code. But when user enter the <code>EnterKey</code>, it is calling 2 button event on server side. I want to call only one event.</p>
  </blockquote>
  
  <p>I have three Asp.net buttons, </p>
  
  <pre><code>&lt;asp:Button ID="btnSearch" class="btn btn-info" runat="server" Text="SEARCH" Width="100" OnClick="btnSearch_Click" /&gt;
  &lt;asp:Button ID="btnSaveFile" runat="server" Text="SaveFile" OnClick="btnSaveFile_Click"/&gt;
  &lt;asp:Button ID="btnLoadData" CssClass="btn btn-info"  runat="server" Text="Ok" OnClick="btnLoadData_Click" /&gt;
  </code></pre>
  
  <blockquote>
    <p>Those 3 buttons will perform 3 different things. I have a textbox, once user enter the data and when they press the enter I want to call the <code>btnSaveFile</code> click event.</p>
  </blockquote>
  
  <p>This is that text box</p>
  
  <pre><code>&lt;asp:TextBox ID="txtFileName" CssClass="form-control" runat="server"&gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p><strong>Note</strong></p>
  
  <blockquote>
    <p>I already define the <strong>click function for btnSaveFile</strong> here is the code</p>
  </blockquote>
  
  <pre><code>$('#btnSaveFile').click(function () {
      var fileNames = $('#txtFileName').val();
      var flag = 'returnTrue';
      $.ajax({
          url: 'ReportTotalSalesPivot.aspx/getFileExistOrNot',
          method: 'post',
          async: false,
          contentType: 'application/json',
          data: '{fileName:"' + fileNames + '",reportName:"TotalSales"}',
          dataType: 'json',
          success: function (data) {
              if (data.d === 'dataExist') {
                  flag = 'returnFalse';
                  $('#lblSaveErrorMsg').text('This filename already exist. Please change the name');
              }
              else {
                  //alert('else');
                  $(".FilterTable &gt; tbody &gt; tr").each(function () {
                      $("#hiddenTableRecord").val($("#hiddenTableRecord").val() + $(this).find(".FieldNameID").html() + "$$$" + $(this).find(".OperatorID").html() + "$$$");
                  });
                  $("#hiddenTableRecord").val('');
                  return true;
              }
          },
          error: function (error) {
              alert('Please Call Administrator');
          }
      });
      //alert('faisal'+flag);
      if (flag === 'returnFalse') {
          return false;
      }
  
  });
  </code></pre>
  
  <p>The below code is for to call the above function.</p>
  
  <pre><code>$('#txtFileName').keydown(function (e) {
      //enter key
      var key = e.which;
      if (key == 13) {
          $('#btnSaveFile').click();
          return false;
      }
  })
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <blockquote>
    <p><strong>keydown function</strong> is working fine. But at the same time when I press the enter key <strong>it is calling <code>btnSearch</code> server side code also. It should not call</strong> <code>btnSearch</code>. It should call <code>btnSaveFile</code> on server side</p>
  </blockquote>
  
  <p><strong>Doubt</strong></p>
  
  <blockquote>
    <p>Totally I have 3 server side button, But it is calling only 2 why? (Just want to know the reason). Target: want to call only one button</p>
  </blockquote>
  
  <p>Thanks</p>