473,809 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:AuthCo ntrol_Main1:Aut hControl_Login: imgLogIn'].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:AuthCo ntrol_Main1:Aut hControl_Login: Button1'].click();return
false;} else return true; "

HELP!!

TIA

Grant
Nov 19 '05 #1
7 4487
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***@workshar e.com> wrote in message
news:eT******** ******@TK2MSFTN GP15.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:AuthCo ntrol_Main1:Aut hControl_Login: imgLogIn'].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:AuthCo ntrol_Main1:Aut hControl_Login: Button1'].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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:OP******** ********@tk2msf tngp13.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***@workshar e.com> wrote in message
news:eT******** ******@TK2MSFTN GP15.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:AuthCo ntrol_Main1:Aut hControl_Login: imgLogIn'].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:AuthCo ntrol_Main1:Aut hControl_Login: Button1'].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***@workshar e.com> wrote in message
news:e$******** ******@tk2msftn gp13.phx.gbl...
ok, but can i have a solution to my problem

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:OP******** ********@tk2msf tngp13.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***@workshar e.com> wrote in message
news:eT******** ******@TK2MSFTN GP15.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:AuthCo ntrol_Main1:Aut hControl_Login: imgLogIn'].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:AuthCo ntrol_Main1:Aut hControl_Login: Button1'].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***@workshar e.com> wrote in message
news:e$******** ******@tk2msftn gp13.phx.gbl...
ok, but can i have a solution to my problem

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:OP******** ********@tk2msf tngp13.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***@workshar e.com> wrote in message
news:eT******** ******@TK2MSFTN GP15.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:AuthCo ntrol_Main1:Aut hControl_Login: imgLogIn'].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:AuthCo ntrol_Main1:Aut hControl_Login: Button1'].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="javas cript">
function fnTrapKD(btn){
if (document.all) {
if (event.keyCode == 13) {
event.returnVal ue=false;
event.cancel = true;
btn.click();}}}
</script>

And plug this into Page_Load:
txPassword.Attr ibutes.Add("onk eydown", "fnTrapKD(docum ent.all." &
cmLogin.ClientI D & ")")

Hope this helps..

"Grant Merwitz" <gr***@workshar e.com> wrote in message
news:eT******** ******@TK2MSFTN GP15.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:AuthCo ntrol_Main1:Aut hControl_Login: imgLog
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:AuthCo ntrol_Main1:Aut hControl_Login: Button
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******** ******@tk2msftn gp13.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="javas cript">
function fnTrapKD(btn){
if (document.all) {
if (event.keyCode == 13) {
event.returnVal ue=false;
event.cancel = true;
btn.click();}}}
</script>

And plug this into Page_Load:
txPassword.Attr ibutes.Add("onk eydown", "fnTrapKD(docum ent.all." &
cmLogin.ClientI D & ")")

Hope this helps..

"Grant Merwitz" <gr***@workshar e.com> wrote in message
news:eT******** ******@TK2MSFTN GP15.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:AuthCo ntrol_Main1:Aut hControl_Login: imgLog
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:AuthCo ntrol_Main1:Aut hControl_Login: Button
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******** ********@TK2MSF TNGP15.phx.gbl. ..
Michael,

Wouldn't that only work in Internet Explorer?

-Jeff

"Michael" <xxx.xxx.xxx> wrote in message
news:O2******** ******@tk2msftn gp13.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="javas cript">
function fnTrapKD(btn){
if (document.all) {
if (event.keyCode == 13) {
event.returnVal ue=false;
event.cancel = true;
btn.click();}}}
</script>

And plug this into Page_Load:
txPassword.Attr ibutes.Add("onk eydown", "fnTrapKD(docum ent.all." &
cmLogin.ClientI D & ")")

Hope this helps..

"Grant Merwitz" <gr***@workshar e.com> wrote in message
news:eT******** ******@TK2MSFTN GP15.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:AuthCo ntrol_Main1:Aut hControl_Login: imgLog 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:AuthCo ntrol_Main1:Aut hControl_Login: Button 1'].click();return
false;} else return true; "

HELP!!

TIA

Grant



Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3324
by: Michael | last post by:
Thank you for any help you can provide. This is what I have: index.aspx - contains nothing but a form with runat = server header.ascx - contains asp image box welcome.ascx - contains text footer.ascx - contains text login.ascx - contains asp/web labels and text boxes. The index page is simply a container for all the user controls. The
2
3122
by: 23s | last post by:
My site's login page has a form w/ 2 textboxes and a submit button. If I'm in either of those textboxes (i.e., either one of the textboxes has focus), in any given browser, hitting "enter" on my keyboard submits the form. Server side, I handle the click event of the submit button. This is the expected behavior, and this is the behavior irrespective of what browser I use on the login page. However... I have different page that is an...
1
2478
by: Tyler Carver | last post by:
I'm using the Layout Template for the Login Control. I've included all the neccessary controls on the page and everything is working nicely except hitting the enter key on any of the textboxes will not fire the login event. This functionality is included if I am not using the Layout Template. Do I need to add custom code to add this event back in? Any ideas on how I might do that? Thanks, Tyler Carver
13
6237
by: Michael | last post by:
I have setup a public variable in the Master Page "code-behind-file". Now I would like to set that value from the UserControl, but I can't seem to find a way to do this. Does anyone have any ideas? I'm basically trying to set it up so that I can keep the User infor (userid, ect) in the Masterpage so that other pages can access it. Thanks for any ideas. Michael
2
278
by: gauravkg via DotNetMonster.com | last post by:
how to transfer values from user control to a page using properties can one explain with code -- Message posted via http://www.dotnetmonster.com
3
3787
by: hary08 | last post by:
im doing a database for Hospital Admission, I have a log in form which prompt user for a password. The source of log in is to look for the values in my Table tblEmployees and match user name and password entered.My case now is I have Audit Trail Module which keeps records of modifications and current user, I wanted my audit trail to log the current user based on who has log from based on my Log in Form.please help ty HERES THE CODE FOR ON...
2
9838
by: AlecL | last post by:
Hi All, I have added a user control onto an aspx page and want to make the submit button of that user control the default button when the panel in which the user control is located is visible. I have used the code: Page.RegisterHiddenField("__EVENTTARGET", "Login.btnSubmit") in the Page Load event but this does not make the submit button default(enter) button. Any ideas on how can I do this. I have also tried using just the name of...
3
4343
by: =?Utf-8?B?RHVrZSAoQU4yNDcp?= | last post by:
The majority of pages on our site need authentication (forms auth against the aspnetdb database). I created an '~/auth' folder with its own config file forcing authentication for any pages in the folder. The default.aspx sits in the root folder and just does a Response.Redirect to an ~/auth/home.aspx page. The config forces authentication, which is carried out by ~/pub/login.aspx which has a standard asp:login control. I set up the...
13
3264
JodiPhillips
by: JodiPhillips | last post by:
G'day, I have a silly and simple problem that I need some guidance with. Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log in procedures via a log in table within the database. This works fine. I have now expanded this table to include further data about the authorised user – Power User, Team Leader, & Facilitator. Depending on the user’s status as to which one of...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10635
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10378
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7653
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.