在aspx页面上我在表单中有一个asp:login控件。当我按下登录按钮时,一切正常,但是当我按Enter键时,页面被重新加载,但没有其他事情发生。登录按钮处理函数不被访问。在ASP中输入密码登录
在ASPX:
<form id="form1" class="login-form" runat="server" DefaultButton="lgLogin$LoginButton">
<asp:Login ID="lgLogin" runat="server" Width="100%"
FailureText="Some text here"
PasswordRequiredErrorMessage="Some text here"
UserNameRequiredErrorMessage="Some text here"
TextLayout="TextOnLeft"
OnAuthenticate="lgLogin_Authenticate"
DestinationPageUrl="~/Welcome.aspx"
OnLoginError="lgLogin_Error"
DisplayRememberMe="False" >
<LayoutTemplate>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Login</label>
<div class="input-icon">
<i class="fa fa-user"></i>
<asp:TextBox runat="server" type="text" ID="UserName" CssClass="form-control placeholder-no-fix" placeholder="Login" />
</div>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Password</label>
<div class="input-icon">
<i class="fa fa-lock"></i>
<asp:TextBox runat="server" type="password" ID="Password" CssClass="form-control placeholder-no-fix" placeholder="Password" />
</div>
</div>
<div id="AlertError" runat="server" class="alert alert-danger" visible="false">
<button class="close" data-close="alert"></button>
<span>
<asp:Label ID="FailureText" runat="server" ></asp:Label>
</span>
</div>
<div class="form-actions">
<asp:Button type="submit" class="btn blue pull-right" ID="LoginButton" runat="server" CommandName="Login" Text='Login now' />
</div>
</LayoutTemplate>
<TextBoxStyle CssClass="form-control placeholder-no-fix"/>
<LoginButtonStyle CssClass="btn blue pull-right" />
</asp:Login>
</form>
按下LoginButton时lgLogin_authenticate空腔仅访问。
编辑
它解决。事实上,它运作良好。问题出在一个.js文件上,它被加载到这个页面中。它捕获回车键来做一些检查,但最后它没有调用提交按钮。
该死!我花了太多时间才意识到这也是我的问题!它现在工作! –