Reputation: 7557
This is my markup:
<asp:UpdatePanel ID="updPnl" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox runat="server" ID="txtEmail" AutoPostBack="true" OnTextChanged="txtEmail_TextChanged" />
<asp:Panel runat="server" Visible="false" ID="pnl">
<asp:TextBox runat="server" ID="txtUname" AutoPostBack="true" OnTextChanged="txtUname_TextChanged" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
and this is the code behind:
and these are the event handlers in the code behind:
protected void txtEmail_TextChanged(object sender, EventArgs e)
{
pnl.Visible = true;
updPnl.Update();
txtUname.Focus();
}
protected void txtUname_TextChanged(object sender, EventArgs e)
{
}
If I press enter on txtEmail
textbox it works fine in all browsers and the focus comes to txtUName
textbox except Chrome. On debugging I found that is happening because Chrome makes Ajax request twice. Is there anyway to fix this Chrome bug?
Note that it works fine in Chrome too if I use Tab instead of enter. However, I need to fix this Chrome bug of Enter too.
Upvotes: 0
Views: 671
Reputation: 196
you may enter key trigger a post to the form, you should prevent the submit action on enter (so enter key and tab key would have the same behavior)
you can do it with JavaScript (onkeydown) for instance.
however, I think update panel here is an overkill, why not to use only JavaScript on the client side?
$("#txtEmail").change(function() {
var email = $(this).val();
// now you can do whatever you want with the value.
});
Upvotes: 1