如何使用回车键登录web应用程序? [英] How to use enter key to login in web applicatoin ?

查看:97
本文介绍了如何使用回车键登录web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai

如何使用键盘输入密钥登录网络应用程序而不使用焦点()。请回复asap





问候

Aravind

Hai
How to use enter key from keyboard to login in web application not use focus().pls reply asap


Regards
Aravind

推荐答案

http://stackoverflow.com/questions/2999961/enter-key-for-login-form [ ^ ]


下面是示例代码您。希望它会有所帮助



Below is the sample code for you. Hope it will help

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"  runat="server">
    <title>Untitled Page</title>
 
    <script language="Javascript">
 
function CheckKey() {
    switch (event.keyCode) {
    case 13:
    Login();
    break;
    default:
    //nothing
    }
}
 
function Login(){
document.getElementById("btnLogin").click();
}


   </script>

</head>
<body >
    <form id="form1"  runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        
    </div>
    <asp:Button ID="btnLogin" runat="server" Text="Login" />
    </form>
    <script>
document.body.onkeydown=CheckKey();

</script>
</body>
</html>


将您的登录控件放在面板中并设置面板的 DefaultButton 属性作为登录按钮。

Put your login controls inside a Panel and set the DefaultButton property of the panel as your Login Button.
<asp:Panel runat="server" ID="pnlLogin" DefaultButton="btnLogin">
     Put your login textboxes and buttons here.
</asp:Panel>







- Amit


这篇关于如何使用回车键登录web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆