Solved

Is There a way to fire the Click Event for a server Button Control with <ENTER> ??

Posted on 2008-11-02
1
224 Views
Last Modified: 2013-11-26
Greetings Experts!
I wonder if there is a way to accomplish what I have in mind, I hope someone could help me with  this. The Thing is, On one of my web pages (Default2.aspx), I have several server button  controls, <asp:Button runat=server>, and I have a textbox control, is there a way to fire the click event for one specific Button control when the user presses on the <ENTER> key on the keyboard??

Thanks in advannce.

~salman~
0
Comment
Question by:salman_sulaiman_2008
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
dhanushkad earned 500 total points
ID: 22861403
Step 1 : Create a Panel (or use the Form object for the global Default Button) that will encompass both the object you want to apply the default action to (usually a Textbox) and the object that actually invokes the action (usually a Button, ImageButton or LinkButton) .

Step 2 : Create the Button object and make sure to give it both an ID and set the runat attribute to "server".

Step 3 : In the opening tag of the Panel , set the DefaultButton property to be the value of the ID property of your Button object.

Sample code :

<body>
    <form id="form1" runat="server" >
    <div>
        <asp:Panel ID="Panel1" runat="server" DefaultButton="btnOk">
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            &nbsp;&nbsp;
            <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
            <asp:Button ID="btnOk" runat="server" Text="Ok" OnClick="btnOk_Click" />
          </asp:Panel>
     </div>
    </form>
</body>
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
original content 7 79
Show MP4 file and close (HTA) 3 22
Calculating percentage 2 30
PowerShell: ForEach-Object Export to CSV 4 42
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question