Solved

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

Posted on 2008-11-02
1
225 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
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.

690 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