Dis*_*oat 10 c# asp.net login enter submit
我有一个标准的asp:登录控件:
<asp:Login ID="mbLogin" runat="server" TitleText=""
DestinationPageUrl="~/Default.aspx"
PasswordRecoveryText="Forgot your password?"
PasswordRecoveryUrl="~/LostPassword.aspx"></asp:Login>
Run Code Online (Sandbox Code Playgroud)
在Internet Explorer中,按Enter键不提交表单,但IE会快速向我发出10次哔声.在其他浏览器中,Enter完全正常,并按照您的期望提交论坛.
我已经看到了这个问题,但只有当你的实际表单元素有一个实际的按钮而不是整个登录控件时才会有效.
为什么它在IE中被阻止(为什么有10次出于某种原因)?有解决方法吗?
ric*_*ott 10
在Login控件的设计器中:"转换为模板".然后在Page Load中通过查找LoginButton来设置表单的defaultButton.
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>
Run Code Online (Sandbox Code Playgroud)
代码隐藏:
protected void Page_Load(object sender, EventArgs e)
{
Button lbButton = Login1.FindControl("LoginButton") as Button;
form1.DefaultButton = lbButton.UniqueID;
}
Run Code Online (Sandbox Code Playgroud)