473,320 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Enter Key

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
Nov 18 '05 #1
3 1828
Jos
Ganesh Ramamurthy wrote:
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" />

--

Jos
Nov 18 '05 #2
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()).

"Ganesh Ramamurthy" <ga****@kottsoftware.com> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #3
You can intercept the client side enter keypress event of the text box and
then do what you want using javascript code.
Here's a good example:
http://www.kamp-hansen.dk/pages/show...d=21&menuid=18

You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx

And here's a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/20...200406so_f.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Ganesh Ramamurthy" <ga****@kottsoftware.com> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: junk mail | last post by:
My friend is trying to code a small c program where he wants to force the user to press enter and only enter to continue. Currently he is using getchar() with a loop but you can type any number...
5
by: ewillyb | last post by:
Hi, ASP.NET has some interesting behavior when the user hits the Enter key. If there are multiple ASP:Buttons (rendered as HTML submits) on the form, when the user hits enter, the first button's...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
6
by: Clark Sann | last post by:
Can someone help me understand what object should be used as the lock object? I've seen some programs that use Monitor.Enter(Me). Then, in those same programs, they sometimes use another object. ...
7
by: Marc | last post by:
Hi, I want my user to be able to rename a button control by selcting rename from a menu. This then opens a text box in which to enter the new name in. I want the button control to...
18
by: Zytan | last post by:
I want the same function to be run whether you press Enter or double click the listbox. It seems really verbose to write both handlers to both events everytime, even if they both call the same...
2
by: JWest46088 | last post by:
I want the user to enter information, such as names, and then I want to ask them after they entered the first name if they want to enter another name. How would I do that? This is what I have so...
7
by: Rotsey | last post by:
Hi, I am having a problem trying to select an item with the enter key. I want to work the combo with the keyboard. So when I use the down arrow to browse the list I want to then hit the...
24
by: MichaelK | last post by:
Who knows how to prevent submitting a form on the press Enter button before all fields on the form are filled up. People just enter the first field hit Enter and it submits the form and doing...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.