允许Enter键在asp.net登录? [英] Allow Enter key to login in asp.net?

查看:191
本文介绍了允许Enter键在asp.net登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标准的asp:登录控件:

I have a standard asp:login control:

<asp:Login ID="mbLogin" runat="server" TitleText=""
  DestinationPageUrl="~/Default.aspx"
  PasswordRecoveryText="Forgot your password?"
  PasswordRecoveryUrl="~/LostPassword.aspx"></asp:Login>

在Internet Explorer中,pressing输入不提交的形式,但在IE浏览器发出哔哔声我迅速的10倍。在其他浏览器中输入工作完全正常,并提交为你所期望的论坛。

In Internet Explorer, pressing Enter does not submit the form, but IE beeps at me 10 times rapidly. In other browsers Enter works perfectly fine and submits the forum as you'd expect.

我见过的<一个href=\"http://stackoverflow.com/questions/399826/how-to-submit-a-form-using-the-enter-key-in-asp-net\">this问题但只有当你有一个实际的按钮,而不是登录控制为一体。实际的表单元素的作品

I've seen this question but that only works when you have actual form element with an actual button, not the login control as a whole.

为什么被挡在IE(为什么10倍出于某种原因)?有没有解决办法?

Why is it being blocked in IE (and why 10 times for some reason)? Is there a workaround?

推荐答案

在您的登录控制的设计师转换成模板。然后在页面加载设置表单的 defaultButton 通过查找在 LoginButton

In the designer of your Login control: "Convert To Template". Then in the Page Load set the defaultButton of your form by finding the LoginButton.

ASPX:搜索

<form id="form1" runat="server">
    <div>
        <asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate">
            <LayoutTemplate>
                <table border="0" cellpadding="1" cellspacing="0" style="border-collapse: collapse;">
                    <tr>
                        <td>
                            <table border="0" cellpadding="0">
                                .....
                                <tr>
                                    <td align="right" colspan="2">
                                        <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="Login1" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
        </asp:Login>
    </div>
    </form>

code-背后:搜索

    protected void Page_Load(object sender, EventArgs e)
    {
        Button lbButton = Login1.FindControl("LoginButton") as Button;
        form1.DefaultButton = lbButton.UniqueID;
    }

这篇关于允许Enter键在asp.net登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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