472,958 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 3558
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
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
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
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
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
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
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
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
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
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
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.