asp.net登录控件。单击enter时,提交登录

时间:2012-01-30 01:55:15

标签: c# asp.net

我有一个asp.net登录控件。它工作正常,但您必须按实际按钮登录才能登录。如果用户也按下回车,我想这样做。怎么办呢?

3 个答案:

答案 0 :(得分:1)

请查看此StackOverflow question

答案 1 :(得分:0)

不确定这是否是您要查找的内容,但请查看AccessKey property

答案 2 :(得分:0)

有一些解决方法。看看代码片段。 (无需添加面板控件)

 protected void Page_Load(object sender, EventArgs e)
    {
     TextBox Password = (TextBox)Login1.FindControl("Password");
     Button ButtonLogin = (Button)Login1.FindControl("LoginButton");
     Password.Attributes.Add("onKeyPress", "javascript:if (event.keyCode == 13) __doPostBack('" + ButtonLogin.UniqueID + "','')");
    }