I'm trying to authenticate the user login in c#. I get the following 2 errors: 'the name 'login_username ' does not exist in the current context' and 'the name 'login_password ' does not exist in the current context'.
index.aspx
index.aspx.cs
Thanks in advance for the help!
index.aspx
Code:
<tr>
<td> </td>
<td>
<asp:TextBox ID="login_username" runat="server" Width="160px"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="login_password" TextMode="password" runat="server" Width="160px"></asp:TextBox>
</td>
<td>
<asp:Button id="btnLogin" class ="btn" Text="Login" onClick="btnLogin_Authenticate" runat="server" Width="50px" />
</td>
</tr>
Code:
protected void btnLogin_Authenticate(object sender, AuthenticateEventArgs e)
{
try
{
string username; //Get the email from the control
string password; //Get the password from the control
username = login_username.Text;
password = login_password.Text;
bool flag = AuthenticateUser(username, password);
if (flag == true)
{
e.Authenticated = true;
string randomString = Guid.NewGuid().ToString();
string url = "companyadmin.aspx?";
url += randomString;
Response.Redirect(url);
}
else
e.Authenticated = false;
Response.Redirect("~/loginattempt.aspx?retry");
}
catch (Exception)
{
e.Authenticated = false;
}
}
Comment