By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,509 Members | 1,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,509 IT Pros & Developers. It's quick & easy.

user enter key to control my login form

P: n/a
Hi

I am trying to get the enter key to submit my login form
The login form is currently in a control on the page and uses an
asp:imagebutton as it's login button.

If a user presses enter currently, the page just reloads.
I have tried to use some javascript to set the enter key on the button, but
this script only seems to work for an asp:button and not the
asp:imagebutton.
Any help on how to do this would be greatly appreciated.

The javascript i am using currently is: (attached to the password textbox)
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:imgLo gIn'].click();return
false;} else return true; "
- This still refreshes the page when enter is click i.e. its not working

When i place a asp:button on the page that calls the same method as the
asp:imagebutton, this works fine
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:Butto n1'].click();return
false;} else return true; "

HELP!!

TIA

Grant
Nov 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
The document reloads because it has posted back.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:eT**************@TK2MSFTNGP15.phx.gbl...
Hi

I am trying to get the enter key to submit my login form
The login form is currently in a control on the page and uses an
asp:imagebutton as it's login button.

If a user presses enter currently, the page just reloads.
I have tried to use some javascript to set the enter key on the button,
but this script only seems to work for an asp:button and not the
asp:imagebutton.
Any help on how to do this would be greatly appreciated.

The javascript i am using currently is: (attached to the password textbox)
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:imgLo gIn'].click();return
false;} else return true; "
- This still refreshes the page when enter is click i.e. its not working

When i place a asp:button on the page that calls the same method as the
asp:imagebutton, this works fine
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:Butto n1'].click();return
false;} else return true; "

HELP!!

TIA

Grant

Nov 19 '05 #2

P: n/a
ok, but can i have a solution to my problem

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OP****************@tk2msftngp13.phx.gbl...
The document reloads because it has posted back.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:eT**************@TK2MSFTNGP15.phx.gbl...
Hi

I am trying to get the enter key to submit my login form
The login form is currently in a control on the page and uses an
asp:imagebutton as it's login button.

If a user presses enter currently, the page just reloads.
I have tried to use some javascript to set the enter key on the button,
but this script only seems to work for an asp:button and not the
asp:imagebutton.
Any help on how to do this would be greatly appreciated.

The javascript i am using currently is: (attached to the password
textbox)
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:imgLo gIn'].click();return
false;} else return true; "
- This still refreshes the page when enter is click i.e. its not working

When i place a asp:button on the page that calls the same method as the
asp:imagebutton, this works fine
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:Butto n1'].click();return
false;} else return true; "

HELP!!

TIA

Grant


Nov 19 '05 #3

P: n/a
Grant,

I've run into this bug before. Place a hidden html textbox somewhere in
the form.

<INPUT type="text" style="DISPLAY:none">

Then when you hit enter in the login field it should fire the login button's
click event.

-Jeff
"Grant Merwitz" <gr***@workshare.com> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
ok, but can i have a solution to my problem

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OP****************@tk2msftngp13.phx.gbl...
The document reloads because it has posted back.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:eT**************@TK2MSFTNGP15.phx.gbl...
Hi

I am trying to get the enter key to submit my login form
The login form is currently in a control on the page and uses an
asp:imagebutton as it's login button.

If a user presses enter currently, the page just reloads.
I have tried to use some javascript to set the enter key on the button,
but this script only seems to work for an asp:button and not the
asp:imagebutton.
Any help on how to do this would be greatly appreciated.

The javascript i am using currently is: (attached to the password
textbox)
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:imgLo gIn'].click();return
false;} else return true; "
- This still refreshes the page when enter is click i.e. its not working

When i place a asp:button on the page that calls the same method as the
asp:imagebutton, this works fine
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:Butto n1'].click();return
false;} else return true; "

HELP!!

TIA

Grant



Nov 19 '05 #4

P: n/a
From what I've read so far, you don't HAVE a problem. The ENTER key is
submitting the form. Of course, you don't need all that code to do it. The
ENTER key submits the form by default. The problem you stated was that you
wanted the ENTER key to submit the form.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
ok, but can i have a solution to my problem

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OP****************@tk2msftngp13.phx.gbl...
The document reloads because it has posted back.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:eT**************@TK2MSFTNGP15.phx.gbl...
Hi

I am trying to get the enter key to submit my login form
The login form is currently in a control on the page and uses an
asp:imagebutton as it's login button.

If a user presses enter currently, the page just reloads.
I have tried to use some javascript to set the enter key on the button,
but this script only seems to work for an asp:button and not the
asp:imagebutton.
Any help on how to do this would be greatly appreciated.

The javascript i am using currently is: (attached to the password
textbox)
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:imgLo gIn'].click();return
false;} else return true; "
- This still refreshes the page when enter is click i.e. its not working

When i place a asp:button on the page that calls the same method as the
asp:imagebutton, this works fine
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:Butto n1'].click();return
false;} else return true; "

HELP!!

TIA

Grant



Nov 19 '05 #5

P: n/a
I'm assuming you want to validate the user on an enter keypress and redirect
to an appropriate page based on the results. There is a difference between
submit in asp.net and submit in asp. It's a good idea to understand the
differences...

Anyway, put this jscript in the html:
<script language="javascript">
function fnTrapKD(btn){
if (document.all) {
if (event.keyCode == 13) {
event.returnValue=false;
event.cancel = true;
btn.click();}}}
</script>

And plug this into Page_Load:
txPassword.Attributes.Add("onkeydown", "fnTrapKD(document.all." &
cmLogin.ClientID & ")")

Hope this helps..

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:eT**************@TK2MSFTNGP15.phx.gbl...
Hi

I am trying to get the enter key to submit my login form
The login form is currently in a control on the page and uses an
asp:imagebutton as it's login button.

If a user presses enter currently, the page just reloads.
I have tried to use some javascript to set the enter key on the button, but this script only seems to work for an asp:button and not the
asp:imagebutton.
Any help on how to do this would be greatly appreciated.

The javascript i am using currently is: (attached to the password textbox)
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:imgLo g
In'].click();return false;} else return true; "
- This still refreshes the page when enter is click i.e. its not working

When i place a asp:button on the page that calls the same method as the
asp:imagebutton, this works fine
onkeydown="if (event.keyCode && event.keyCode == 13)
{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:Butto n
1'].click();return false;} else return true; "

HELP!!

TIA

Grant

Nov 19 '05 #6

P: n/a
Michael,

Wouldn't that only work in Internet Explorer?

-Jeff

"Michael" <xxx.xxx.xxx> wrote in message
news:O2**************@tk2msftngp13.phx.gbl...
I'm assuming you want to validate the user on an enter keypress and
redirect
to an appropriate page based on the results. There is a difference between
submit in asp.net and submit in asp. It's a good idea to understand the
differences...

Anyway, put this jscript in the html:
<script language="javascript">
function fnTrapKD(btn){
if (document.all) {
if (event.keyCode == 13) {
event.returnValue=false;
event.cancel = true;
btn.click();}}}
</script>

And plug this into Page_Load:
txPassword.Attributes.Add("onkeydown", "fnTrapKD(document.all." &
cmLogin.ClientID & ")")

Hope this helps..

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:eT**************@TK2MSFTNGP15.phx.gbl...
Hi

I am trying to get the enter key to submit my login form
The login form is currently in a control on the page and uses an
asp:imagebutton as it's login button.

If a user presses enter currently, the page just reloads.
I have tried to use some javascript to set the enter key on the button,

but
this script only seems to work for an asp:button and not the
asp:imagebutton.
Any help on how to do this would be greatly appreciated.

The javascript i am using currently is: (attached to the password
textbox)
onkeydown="if (event.keyCode && event.keyCode == 13)

{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:imgLo g
In'].click();return
false;} else return true; "
- This still refreshes the page when enter is click i.e. its not working

When i place a asp:button on the page that calls the same method as the
asp:imagebutton, this works fine
onkeydown="if (event.keyCode && event.keyCode == 13)

{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:Butto n
1'].click();return
false;} else return true; "

HELP!!

TIA

Grant


Nov 19 '05 #7

P: n/a
Yes.

"Jeff Sheldon" <ni****@gmx.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Michael,

Wouldn't that only work in Internet Explorer?

-Jeff

"Michael" <xxx.xxx.xxx> wrote in message
news:O2**************@tk2msftngp13.phx.gbl...
I'm assuming you want to validate the user on an enter keypress and
redirect
to an appropriate page based on the results. There is a difference between submit in asp.net and submit in asp. It's a good idea to understand the
differences...

Anyway, put this jscript in the html:
<script language="javascript">
function fnTrapKD(btn){
if (document.all) {
if (event.keyCode == 13) {
event.returnValue=false;
event.cancel = true;
btn.click();}}}
</script>

And plug this into Page_Load:
txPassword.Attributes.Add("onkeydown", "fnTrapKD(document.all." &
cmLogin.ClientID & ")")

Hope this helps..

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:eT**************@TK2MSFTNGP15.phx.gbl...
Hi

I am trying to get the enter key to submit my login form
The login form is currently in a control on the page and uses an
asp:imagebutton as it's login button.

If a user presses enter currently, the page just reloads.
I have tried to use some javascript to set the enter key on the button,

but
this script only seems to work for an asp:button and not the
asp:imagebutton.
Any help on how to do this would be greatly appreciated.

The javascript i am using currently is: (attached to the password
textbox)
onkeydown="if (event.keyCode && event.keyCode == 13)

{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:imgLo g In'].click();return
false;} else return true; "
- This still refreshes the page when enter is click i.e. its not working
When i place a asp:button on the page that calls the same method as the
asp:imagebutton, this works fine
onkeydown="if (event.keyCode && event.keyCode == 13)

{document.Form1.elements['Header1:AuthControl_Main1:AuthControl_Login:Butto n 1'].click();return
false;} else return true; "

HELP!!

TIA

Grant



Nov 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.