登陆 回车直接进入
asp.net:
cs代码:
TextBox1.Attributes.Add("onkeydown", "SubmitKey('Button1');");
TextBox2.Attributes.Add("onkeydown", "SubmitKey('Button1');");
js代码:
<script type="text/javascript">
function SubmitKey(button)
{
if (event.keyCode == 13)
{
event.returnValue = false;
document.all[button].click();
}
}
</script>
TextBox1和TextBox2对应用户名和密码框!!
Button1对应是提交按钮!!
winform:
private void txtUserPassword_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
btnOK_Click(sender, e);
}
else
{
return;
}
}