Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8296465

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:00:31+00:00 2026-06-08T15:00:31+00:00

My question is about handling Enter key press.I have one page called order.aspx which

  • 0

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

1. <asp:TextBox ID="txtSearch" MaxLength="50" runat="server" Width="420px" CssClass="txtbox"></asp:TextBox>

2. <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" />

3. one asp grid control with one column containing textbox for entering order quantity 

4. <asp:Button ID="btnOrder" runat="server" OnClick="btnOrder_Click" />.

My requirement is,

  1. while user enter text in the search textbox and press enter key then btnSearch_Click should fire
  2. while user enter quantity in the grid textbox and press enter key then btnOrder_Click should fire.

I tried with different code finally got answers but it is not fully functional.Follwing is the javascript code i have used.

function DoEnterKeyButtonClick(buttonId) {
     e = event;
     var code = (e.keyCode ? e.keyCode : e.which);
     if (code == 13) {
         document.getElementById('ctl00_CphMaster_' + buttonId).click();
         return false;
     }
}

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…

Thanks,
Joby

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:00:35+00:00Added an answer on June 8, 2026 at 3:00 pm

    Instead of giving this document.getElementById('ctl00_CphMaster_' + btnSearch).click();

    Try this document.getElementById('<%= btnSearch.ClientID %>').click();

    or try using jquery

    $("#txtSearch").keyup(function(event){
        if(event.keyCode == 13){
            $("#btnSearch").click();
        }
    });
    

    Else place your controls inside the asp:panel and set the DefaultButton property as btnSearch as like below

    <asp:Panel ID="Panel1" runat="server" DefaultButton="btnSearch">
        <asp:TextBox ID="txtSearch" MaxLength="50" runat="server" Width="420px" CssClass="txtbox"></asp:TextBox>
        <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" />
        </asp:Panel>
    

    Hope this will help.

    Many Thanks
    Anna

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about handling my models. I get all confused. When I
I have a question about Symbian active objects handling. What's the problem: my program
Just started with Android, and I have a question about handling images. I'm thinking
I have a question about handling exception. I have a Winform that uses a
I'm new to Rails development and I have a question about handling an unknown
I have a question about event handling with C#. I listen to events a
I have a question about form handling with OO programming, The way I am
I have a question about error/exception handling on the iPhone. I've read the documentation
I have a question about exception handling. To prevent the [YourProgram] has stopped working
I have a simple question about event handling in iOS applications... suppose you have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.