Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Hitting the enter key

Reply
Thread Tools

Hitting the enter key

 
 
Andy G
Guest
Posts: n/a
 
      12-27-2004
I have a login page w/ a few buttons on it. When the user types in their
username and password and hits the "Enter" key the applications runs the on
click event for another button on the page. I don't think tab control has
much to do with this. I need it so whenever someone hits the enter key it
needs to fire the "Login" button. The login button is defined as an HTML
Input control and all the other button is an ASP button (I'm sure this has
something to do with it)

Thanks


 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      12-27-2004
You can intercept the client side enter keypress event of the text box and
then do what you want using javascript code.

Here are a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/20...200406so_f.asp

You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"Andy G" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a login page w/ a few buttons on it. When the user types in their
> username and password and hits the "Enter" key the applications runs the
> on
> click event for another button on the page. I don't think tab control has
> much to do with this. I need it so whenever someone hits the enter key it
> needs to fire the "Login" button. The login button is defined as an HTML
> Input control and all the other button is an ASP button (I'm sure this has
> something to do with it)
>
> Thanks
>
>



 
Reply With Quote
 
 
 
 
Ken Dopierala Jr.
Guest
Posts: n/a
 
      12-28-2004
Hi,

Here is how I do it:

My <body> tag looks like this:

<body MS_POSITIONING="FlowLayout" onkeypress="CheckSubmit();">

Then my CheckSubmit() routine looks like this:

<script language="javascript">
function CheckSubmit() {
if (event.keyCode == 13) {
document.getElementById("btnLogin").focus();
}
}
</script>

Everytime a key is pressed it calls the CheckSubmit() routine. If the
keycode is 13 (Enter), then it sets focus to the btnLogin control, which in
turn gets fired by letting the event bubble. Remember to change btnLogin to
whatever is the id of your button. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Andy G" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a login page w/ a few buttons on it. When the user types in their
> username and password and hits the "Enter" key the applications runs the

on
> click event for another button on the page. I don't think tab control has
> much to do with this. I need it so whenever someone hits the enter key it
> needs to fire the "Login" button. The login button is defined as an HTML
> Input control and all the other button is an ASP button (I'm sure this has
> something to do with it)
>
> Thanks
>
>



 
Reply With Quote
 
Andy G
Guest
Posts: n/a
 
      12-28-2004
WOW! That is how to reply to a post...to the point, quick fix. Myself and
my clients would like to thank you Ken.



"Ken Dopierala Jr." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> Here is how I do it:
>
> My <body> tag looks like this:
>
> <body MS_POSITIONING="FlowLayout" onkeypress="CheckSubmit();">
>
> Then my CheckSubmit() routine looks like this:
>
> <script language="javascript">
> function CheckSubmit() {
> if (event.keyCode == 13) {
> document.getElementById("btnLogin").focus();
> }
> }
> </script>
>
> Everytime a key is pressed it calls the CheckSubmit() routine. If the
> keycode is 13 (Enter), then it sets focus to the btnLogin control, which

in
> turn gets fired by letting the event bubble. Remember to change btnLogin

to
> whatever is the id of your button. Good luck! Ken.
>
> --
> Ken Dopierala Jr.
> For great ASP.Net web hosting try:
> http://www.webhost4life.com/default.asp?refid=Spinlight
> If you sign up under me and need help, email me.
>
> "Andy G" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I have a login page w/ a few buttons on it. When the user types in

their
> > username and password and hits the "Enter" key the applications runs the

> on
> > click event for another button on the page. I don't think tab control

has
> > much to do with this. I need it so whenever someone hits the enter key

it
> > needs to fire the "Login" button. The login button is defined as an

HTML
> > Input control and all the other button is an ASP button (I'm sure this

has
> > something to do with it)
> >
> > Thanks
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hitting enter or shift+enter in asp.net designer messes up html code? Sunfire ASP .Net 2 11-06-2007 02:44 PM
hitting the "enter" key PJ6 ASP .Net 3 08-25-2005 05:02 AM
Enter Key H*ll, control enter key submit button BrianDH ASP .Net Web Controls 3 01-12-2005 08:29 PM
Replace Tab Key to Return Key (Enter Key) from Web Forms? M P ASP General 1 08-06-2004 08:32 AM
STRUTS-<html:submit> -Hitting enter key does not submit the form Megha Vishwanath Javascript 3 07-20-2004 05:45 AM



Advertisments