简体   繁体   中英

Press Enter Button To Login

Please I am working on a login form, I want it to be that once a user has entered the password and pressed the enter button keyboard, without leaving the textBox, it will just login straight away. How will I do it please?

You can try to set the AcceptButton property of your form to the login button.

Check MSDN Form.AcceptButton Property

Gets or sets the button on the form that is clicked when the user presses the ENTER key.

You can also use a Panel like this

<asp:Panel DefaultButton="YOUR_BUTTON_ID" runat="server" ID="Panel1">

</asp:Panel>
private void textBox_KeyDown(object sender, KeyEventArgs e) 
{
    if (e.KeyCode == Keys.Enter)
    {
        button.PerformClick();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM