I have ASP Login Control in my page and a
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
What I want to do is that when I perform authentication in
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
DAL = new DataAccessLayer();
conObj = DAL.openConnection();
string query = "SELECT * FROM tblUser WHERE UEmail = '"+Login1.UserName+"'";
SqlDataReader SQLDR = DAL.ExecuteQueryReturnValue(query);
if (SQLDR.Read())
{
if (SQLDR["UPassword"].ToString() == Login1.Password.ToString())
{
Session["userName"] = SQLDR["UEmail"].ToString();
e.Authenticated = true;
}
else {
// Change the 'FailureText' to "password is incorrect"
e.Authenticated = false;
}
}
else
{
// Here I want to change the 'FailureText' to "User does not exists"
e.Authenticated = false;
}
}
set the text of FailureText to
"Incorrect Password"
Or set to
"User does not exist"
for both possibilities.
Jayden Bell
09-Dec-2014Try this:
Anonymous User
09-Dec-2014You can declare a string variable within the method and set it accordingly: