468,301 Members | 1,478 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,301 developers. It's quick & easy.

user enter key to control my login form

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
7 4204
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
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
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
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
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
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
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.

Similar topics

4 posts views Thread by Michael | last post: by
1 post views Thread by Tyler Carver | last post: by
2 posts views Thread by gauravkg via DotNetMonster.com | last post: by
3 posts views Thread by =?Utf-8?B?RHVrZSAoQU4yNDcp?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.