471,306 Members | 854 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 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 3487
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by JCO | last post: by
reply views Thread by Lalit Bhatia | last post: by
reply views Thread by Joel Barsotti | last post: by
2 posts views Thread by Greoasy | last post: by
reply views Thread by rosydwin | last post: by

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.