You can try it this way
private int Login(String Username, String Password)
{
int Counter = 0;
if (Username == "Admin" && Password == "wowigotin")
{
//Redirect the User to a Page and set the Counter to 0
Counter = 0;
}
else
{
Counter =1; //Add a in the Counter Variable and keep the user on the login page
}
return Counter;
}
the above is the Function that will return a value of 1 if the login is incorrect and 0 if its correct and in your button to can have something like this
int Counters = Login(txtusername.Text, txtpassword.Text);
Session["Final_Counter"] = Convert.ToInt32(Session["Final_Counter"]) + Counters;
int Res = Convert.ToInt32(Session["Final_Counter"]);
if (Convert.ToInt32(Session["Final_Counter"]) < 3)
{
//Do nothing
}
else
{
Response.Write("<script>alert('User has been locked');</script>");
Session.Abandon();
}
Now please note that this code is merely used for demostration only, this is the worst thing you should do in the application. i was just trying to give you the idea.
Thank you for posting in .NETFUDA , were are looking forward for your reply .
Vuyiswa Maseko
Thank you for posting at Dotnetfunda
[Administrator]
Satyadnet, if this helps please login to Mark As Answer. | Alert Moderator