Enter Key

G

Ganesh Ramamurthy

Hi Experts,

In my aspx page, I have a textbox, a button and a Header user control. In
the Header Conrol, I have a few ImageButtons. When I type something in the
textbox and press "Enter", the click event of one of the Image button is
getting fired. I dont want this to happen. Insted, I want the click event of
the button to be fired.

Can anybody tell me a way to achieve this.

Thanks in advance
Regards
Ganesh
 
J

Jos

Ganesh said:
Hi Experts,

In my aspx page, I have a textbox, a button and a Header user
control. In the Header Conrol, I have a few ImageButtons. When I type
something in the textbox and press "Enter", the click event of one of
the Image button is getting fired. I dont want this to happen.
Insted, I want the click event of the button to be fired.

Can anybody tell me a way to achieve this.

Thanks in advance
Regards
Ganesh

By default, it's the first button on the page that will be used to handle
the Enter event.

Use client-side JavaScript to overcome this problem:
<body onkeydown="if(event.keyCode == 13)
{document.getElementById('myBtn').click();}">
....
<asp:Button id="myBtn" runat="server" Text="Submit" />
 
S

Shiva

You will have to use client-side JS function to capture the ENTER key and
manually fire the event (call <client_side_button_name>.click()).

Hi Experts,

In my aspx page, I have a textbox, a button and a Header user control. In
the Header Conrol, I have a few ImageButtons. When I type something in the
textbox and press "Enter", the click event of one of the Image button is
getting fired. I dont want this to happen. Insted, I want the click event of
the button to be fired.

Can anybody tell me a way to achieve this.

Thanks in advance
Regards
Ganesh
 
S

Steve C. Orr [MVP, MCSD]

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top