Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
what is the c# code for login page when i press enter key.
Posted
Comments
[no name] 23-Jun-11 1:12am    
Please explain in detail what you exactly want. there can be multiple checks to get login on to a page.
tanisha pandey 23-Jun-11 1:21am    
when i was give the login name and password then click on the login button the new form will be open but how i can use the enter key to login the page.

There are three steps:
- the login form should be modal (i.e. shown with ShowDialog)
- it should have an OK/Login/etc button with its DialogResult set to OK (causes the form to be closed and control to return to the code that caused ShowDialog when the button is pressed)
- the form should have its AcceptButton property set to that button (causes the button to be 'pressed' when Enter is pressed)
 
Share this answer
 
Hi,

You need to set a Form Property for it.

Form1.AcceptButton=btnLogin;


Hope it will work for you.

Regards
AR
 
Share this answer
 
You have to set the below code to txtname.KeyUp And to txtPassword.KeyUp
command

C#
if (e.KeyCode=13)
{
     Call LoginEvent();
}


You can set your Login code to LoginEvent()

Thanks.
 
Share this answer
 
Comments
tanisha pandey 23-Jun-11 1:54am    
thank u.
Christian Graus 24-Jun-11 4:13am    
this is pretty bad code, although it will work. Why use the keycode and not the keys value ?
Tarun Mangukiya 24-Jun-11 12:55pm    
It shows the ascii code of the key so we can easily get it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900