title: Responding to an "enter" keypress within an <input> field
body: <p>My question is about handling Enter key press.I have one page called "order.aspx" which is residing inside master page.Here i am explaining the control structure</p>
  
  <pre><code>1. &lt;asp:TextBox ID="txtSearch" MaxLength="50" runat="server" Width="420px" CssClass="txtbox"&gt;&lt;/asp:TextBox&gt;
  
  2. &lt;asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" /&gt;
  
  3. one asp grid control with one column containing textbox for entering order quantity 
  
  4. &lt;asp:Button ID="btnOrder" runat="server" OnClick="btnOrder_Click" /&gt;.
  </code></pre>
  
  <p>My requirement is, </p>
  
  <ol>
  <li>while user enter text in the search textbox and press enter key then btnSearch_Click should fire </li>
  <li>while user enter quantity in the grid textbox and press enter key then btnOrder_Click should fire.</li>
  </ol>
  
  <p>I tried with different code finally got answers but it is not fully functional.Follwing is the javascript code i have used.</p>
  
  <pre><code>function DoEnterKeyButtonClick(buttonId) {
       e = event;
       var code = (e.keyCode ? e.keyCode : e.which);
       if (code == 13) {
           document.getElementById('ctl00_CphMaster_' + buttonId).click();
           return false;
       }
  }
  </code></pre>
  
  <p>I am calling this method on key press of txtSearch and grid textbox and passing the Button id to fire event btnSearch and btnOrder respectively.When i am entering the text in the search textbox and hitting the enter key then btnSearch_Click is firing and when i am entering the order quantity and hitting the enter key the btnOrder_Click is firing.But the issue is,after changing the page index say second page the required functionality not working.That is when i am entering order quantity and hitting the enter key then btnSearch_Click will fire first , then btnOrder_Click firing.This will clear the quantity entered and results in error.Please help me...</p>
  
  <p>Thanks,
  Joby</p>