471,120 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,120 software developers and data experts.

how to fire a image button when user press enter key

i am making u user login page where there are few buttons at the top of the page like Home, Services, About Us etc

and below it i hav
Username -- textbox
Password --textbox
Login --image button...

now after a user hav filled the password box and when he press the enter key then the 'Login' should fire..... but this button is not firing in my case....
the first button is fired i.e Home button is fired...

can u plz xplain....


i have added a OnclientClick= return validateuser() in the <asp:imgbutton> tag and in the <script> tag i have written the following code for checking if the username and password box are not left blank...like this.....

Expand|Select|Wrap|Line Numbers
  2. if(document.getElementById('<%= txtUsername.ClientID%>').value == "")
  3. {
  4. alert('Please enter username');
  5. document.getElementById('<%= txtUsername.ClientID%>').focus();
  6. return false;
  7. }
Jul 14 '08 #1
2 1971
979 Expert 512MB
Moved to .NET Forum.
Jul 14 '08 #2
979 Expert 512MB
So is the problem that when the user presses the enter key the wrong button is being 'clicked' ? If so then put your Username, Password and Login button controls in a panel and set the DefaultButton property of the panel to the ID of the image button.

Hope this helps,

Dr B
Jul 15 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

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.