473,513 Members | 2,456 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 3572
you can use JavaScript to do this.
Add this code to you TextBox (Where tbMyTextBox is the name of your textbox)

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

HTH
"csgraham74" <cs********@hotmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.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***@workshare.com> wrote in message
news:u2****************@TK2MSFTNGP09.phx.gbl...
you can use JavaScript to do this.
Add this code to you TextBox (Where tbMyTextBox is the name of your
textbox)

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

HTH
"csgraham74" <cs********@hotmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.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
71901
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
6544
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...
4
16633
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...
9
6975
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...
0
1261
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....
15
4011
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...
0
895
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...
4
7606
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....
2
2049
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...
1
6966
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...
0
7160
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
7384
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
7537
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...
1
5086
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...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.