473,406 Members | 2,343 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,406 software developers and data experts.

Can't use enter on asp.net form

M K
I have a web form with a listbox and single text box and a single button.
When my users type in the text box and press enter, it doesn't submit. It
refreshes the page and clears the textbox.

Any ideas?
Nov 18 '05 #1
6 1388
yeah submit is done by onclick of a button or a hyperlink. enter doesnt do
the job (as event args need to be populated with right info so what happens
is it just does a page_load and comes back) and what i tend to do is disable
it altogether.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"M K" <ma**@nospamcenturycolor.com> wrote in message
news:16**********************************@microsof t.com...
I have a web form with a listbox and single text box and a single button.
When my users type in the text box and press enter, it doesn't submit. It
refreshes the page and clears the textbox.

Any ideas?

Nov 18 '05 #2
Hi Mark,

Hermit's suggstion is reasonable. The ASP.NET webform need some control to
fire the post back event and not all the controls can fire such event by
default. The "submit button" , "link button" 's click can by default make
the page post back to server. So you need to add a button on the web form
page to let the user post back the page.

In addition, here are some referernce in MSDN on the asp.net's page model
and control events:

#Introduction to ASP.NET and Web Forms
http://msdn.microsoft.com/library/de...us/dndotnet/ht
ml/introwebforms.asp

#Events in ASP.NET Server Controls
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconeventsinwebformscontrols.asp

Hope helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3
M K
I have a button. But many users are used to pressing the enter key after
keying in a password.

"Steven Cheng[MSFT]" wrote:
Hi Mark,

Hermit's suggstion is reasonable. The ASP.NET webform need some control to
fire the post back event and not all the controls can fire such event by
default. The "submit button" , "link button" 's click can by default make
the page post back to server. So you need to add a button on the web form
page to let the user post back the page.

In addition, here are some referernce in MSDN on the asp.net's page model
and control events:

#Introduction to ASP.NET and Web Forms
http://msdn.microsoft.com/library/de...us/dndotnet/ht
ml/introwebforms.asp

#Events in ASP.NET Server Controls
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconeventsinwebformscontrols.asp

Hope helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4
Hi Mark,

Thanks for the followup. Based on your further description, I think this is
a normal behavior of the web page. The asp.net page didn't have the
"default button" feature(which exist in windows form application) by
default.

As for how to make a Button control as the default button on a asp.net
webform page, there is no buildin means for setting default button. We can
use javascript code to let a certain button be clicked when we press
"enter" key on a textbox. Here are some tech articles and former threads
discussing on the same question:
http://www.kamp-hansen.dk/pages/show...d=21&menuid=18

http://www.metabuilders.com/tools/DefaultButtons.aspx

http://www.allasp.net/enterkey.aspx
http://groups.google.com/groups?hl=e...tFHT8DHA.1152%
40cpmsftngxa07.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26
q%3Denter%2Bkey%2Bsteven%2Bcheng

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 18 '05 #5
M K
Thanks. Setting the Event Target worked. That's all I needed.

"Steven Cheng[MSFT]" wrote:
Hi Mark,

Thanks for the followup. Based on your further description, I think this is
a normal behavior of the web page. The asp.net page didn't have the
"default button" feature(which exist in windows form application) by
default.

As for how to make a Button control as the default button on a asp.net
webform page, there is no buildin means for setting default button. We can
use javascript code to let a certain button be clicked when we press
"enter" key on a textbox. Here are some tech articles and former threads
discussing on the same question:
http://www.kamp-hansen.dk/pages/show...d=21&menuid=18

http://www.metabuilders.com/tools/DefaultButtons.aspx

http://www.allasp.net/enterkey.aspx
http://groups.google.com/groups?hl=e...tFHT8DHA.1152%
40cpmsftngxa07.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26
q%3Denter%2Bkey%2Bsteven%2Bcheng

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #6
Hi,

Can you share what you did?

Thnx
"M K" wrote:
Thanks. Setting the Event Target worked. That's all I needed.

"Steven Cheng[MSFT]" wrote:
Hi Mark,

Thanks for the followup. Based on your further description, I think this is
a normal behavior of the web page. The asp.net page didn't have the
"default button" feature(which exist in windows form application) by
default.

As for how to make a Button control as the default button on a asp.net
webform page, there is no buildin means for setting default button. We can
use javascript code to let a certain button be clicked when we press
"enter" key on a textbox. Here are some tech articles and former threads
discussing on the same question:
http://www.kamp-hansen.dk/pages/show...d=21&menuid=18

http://www.metabuilders.com/tools/DefaultButtons.aspx

http://www.allasp.net/enterkey.aspx
http://groups.google.com/groups?hl=e...tFHT8DHA.1152%
40cpmsftngxa07.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26
q%3Denter%2Bkey%2Bsteven%2Bcheng

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 21 '06 #7

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

Similar topics

3
by: Megha Vishwanath | last post by:
Hi, I have a struts form <html:form> in which although the focus rests on the submit button, hitting the enter key does not submit the form. I tried capturing the Enter key event and followed...
4
by: Simon Wigzell | last post by:
Is there a way to prevent a form submitting when you press enter on a text field? Some people press enter when they finish typing in a text field out of habit I guess unconcsciously thinking it...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
7
by: jerrygarciuh | last post by:
Hello, I have been playing with various Googled solutions for capturing the <Enter> key to suppress form submission. My first question is whether anyone has a script that works in all common...
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: Paul Furman | last post by:
I'm getting incorrect response when hitting the enter key instead of actually clicking the button on a form. It activates but the post data isn't being sent I think. The php generated page...
4
by: portCo | last post by:
Hello there, I am using Visual Basic 2005. I want to store a value when I press enter key on the keyboard. Could anyone help me out? Thanks alot.
10
by: sufian | last post by:
I am new to the world of PHP. Below is my simple PHP file "invite.php" with a form having an image send button (I have to use the image send button because it is the requirement, may be this is...
19
by: creative1 | last post by:
hi I am in strange problem. I have javascript for for validation. If I have any entry invalid it prompts me to corrrect it. All checks I have works fine. However, form does not response when there...
5
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all I've got a very complex form with loads of text boxes and buttons on it. It's causing me all sorts of problems when users press the enter key and cause a postback. I need to disable...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.