Hi smile,
Please refer below sample.
Also refer below aricle link-
HTML
<asp:Login ID="Login1" runat="server" OnAuthenticate="ValidateUser">
</asp:Login>
Namespaces
C#
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Web.Security;
Code
C#
protected void ValidateUser(object sender, EventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT * FROM [Users] WHERE UserName = @UserName", con))
{
cmd.Parameters.AddWithValue("@UserName", Login1.UserName);
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
da.Fill(dt);
DateTime loggindate = Convert.ToDateTime(dt.Rows[0]["LastLoginDate"]);
DateTime date = DateTime.Today;
int day = loggindate.Day;
int today = date.Day;
int totalday = day - today;
if (totalday >= 5)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Your acount is temprary disabled.')", true);
}
else
{
FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);
}
}
}
}
}
Screenshot