I'm trying to make a web page with a login screen. I have 2 textboxes that are used to type the username and the password. I'm using an AJAX Update Panel, so in case that username doesn't exist (I'm using SQL Server), it makes visible a label that shows the error. The problem is that when the user types in the username textbox, AutoPostBack fires and when you move to the password textbox, you have to click twice in order to start typing in the password textbox.
C# code:
protected void txtUsername_TextChanged(object sender, EventArgs e)
{
string msgError = businessLogin.checkUsername(txtUsername.Text);
if (msgError != "")
{
lblWrongUser.Text = msgError;
lblWrongUser.Visible = true;
btnLogin.Enabled = false;
}
else
{
lblWrongUser.Visible = false;
btnLogin.Enabled = true;
}
}
ASP.Net:
<asp:TextBox ID="txtUsername" clientidmode="Static" runat="server" OnTextChanged="txtUsername_TextChanged" AutoPostBack="True"></asp:TextBox>