我的页面上有这个
<asp:TextBox Text="" ID="txtEmailOApodo" MaxLength="70" runat="server" Width="250px"
Style="height: 25px"></asp:TextBox>
<asp:TextBox Text="" ID="txtContrasena" MaxLength="50" TextMode="Password" runat="server"
CssClass="textoLightbox"></asp:TextBox>
<div style="margin-top: 20px">
<asp:UpdatePanel runat="server" ID="updPanelLoginIncorrecto">
<ContentTemplate>
<asp:CustomValidator ForeColor="Red" OnServerValidate="usuarioExistente_Validation"
Display="Static" Font-Size="Small" runat="server" ID="vldLogin" Text="<%$ Resources:LocalizedText, MsjError_LoginIncorrecto%>">
</asp:CustomValidator>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnLoginLightbox" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
<div class="tableContent" style="float: right;">
<asp:Button CssClass="button" ID="btnLoginLightbox" Text="Login" runat="server" OnClick="btnLoginUserControl_Click" />
</div>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$("#<%=txtContrasena.ClientID%>").keyup(function (event) {
if (event.keyCode == 13) {
$("#<%=btnLoginLightbox.ClientID%>").click();
}
});
$("#<%=txtEmailOApodo.ClientID%>").keyup(function (event) {
if (event.keyCode == 13) {
$("#<%=btnLoginLightbox.ClientID%>").click();
}
});
});
</script>
在我后面的代码中
protected void btnLoginUserControl_Click(object sender, EventArgs e)
{
//Some code....
}
我不知道为什么当我专注于 txtContrasena 或 txtEmailOApodo 并按回车键时 btnLoginUserControl_Click 会执行两次。