473,587 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enter Press on Text box ASP.Net

Hello,

I wonder if someone could help me.

I have an asp.net form which collects data from a piece of XML and
displays it on screen. If a piece of data is incorrect i will select
the textbox and change the data. If i press enter whilst in the text
box it throws an event.

My question is how do i disable the event or autopostback of the form
when the enter key is pressed whilst in a textbox.

any help greatly appreciated.

CG

Nov 19 '05 #1
2 3582
you can use JavaScript to do this.
Add this code to you TextBox (Where tbMyTextBox is the name of your textbox)

tbMyTextBox.Att ributes.Add("on keydown", "if ((event.which && event.which ==
13) || (event.keyCode && event.keyCode == 13))
{document.Form1 .elements['tbMyTextBox].click();return false;} else return
true; ");

HTH
"csgraham74 " <cs********@hot mail.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com...
Hello,

I wonder if someone could help me.

I have an asp.net form which collects data from a piece of XML and
displays it on screen. If a piece of data is incorrect i will select
the textbox and change the data. If i press enter whilst in the text
box it throws an event.

My question is how do i disable the event or autopostback of the form
when the enter key is pressed whilst in a textbox.

any help greatly appreciated.

CG

Nov 19 '05 #2
and Form1 was your forms name
"Grant Merwitz" <gr***@workshar e.com> wrote in message
news:u2******** ********@TK2MSF TNGP09.phx.gbl. ..
you can use JavaScript to do this.
Add this code to you TextBox (Where tbMyTextBox is the name of your
textbox)

tbMyTextBox.Att ributes.Add("on keydown", "if ((event.which && event.which
== 13) || (event.keyCode && event.keyCode == 13))
{document.Form1 .elements['tbMyTextBox].click();return false;} else return
true; ");

HTH
"csgraham74 " <cs********@hot mail.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com...
Hello,

I wonder if someone could help me.

I have an asp.net form which collects data from a piece of XML and
displays it on screen. If a piece of data is incorrect i will select
the textbox and change the data. If i press enter whilst in the text
box it throws an event.

My question is how do i disable the event or autopostback of the form
when the enter key is pressed whilst in a textbox.

any help greatly appreciated.

CG


Nov 19 '05 #3

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

Similar topics

7
71911
by: JCO | last post by:
How's come when I press the enter key, I can't get it to execute the correct password. It seems that I'm forced to press the button. I want to be able to do both. How is this done?
15
6563
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and the buttons. The problem is when I post a form to itself, the Enter key will not submit the form, it only clears the contents of the text box. The...
4
16643
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 will take them to the next field. Instead it submits the form and this causes all kinds of problems in my case. Any javascript solution?
9
6987
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with...
0
1265
by: Lalit Bhatia | last post by:
I have a problem while using Enter key in text box. when user presses enter in the text box information of customer is loaded. and I have a clear button that clears all the controls on the form. first it works properly. then I click on some other button (say detail button) that opens some other form. after closing that form if clear the form...
15
4028
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 CALLING FORM! This is very bad for me, because in my application, Form1 responds to an ENTER keypress by calling Form2. If the user closes Form2 via an...
0
900
by: Joel Barsotti | last post by:
Hi, So with my search control I want people to be able to enter some text and press enter and have the search submit. I was doing this with javascript using the onKeyPress event for the individual textboxes I wanted to monitor then used the argument to pass the buttonn id I want to click and used more javascript to simulate the click....
4
7614
by: nkoier | last post by:
Hi, I've been going crazy trying to figure out what's wrong with our Asp.Net 2.0 intranet site. At the very top of our main page I provide a TextBox and a Button for submitting Google searches. Recently somebody pointed out to me that you can't just press ENTER anymore after typing in the TextBox but that you HAVE to click on the submit...
2
2054
by: Greoasy | last post by:
I have a registration page with no of text boxes and 3 buttons for insert update and delete. and a logout button on the top of the page. If i place my control in an of the text box and press enter key it automatically goes to the logout button and it logouts. Actually when i press the enter key it should avctivate either of the insert,update...
1
6991
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the page has multiple button such login page with a search function somewhere around, then it's not respond properly. I have attached a brief example of...
0
7923
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7852
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7974
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.