我想阻止用戶登錄進入5分鐘,當他輸入錯誤的密碼時,我通過使用計時器控件禁用了此提交按鈕,但我很困惑5分鐘後如何啓用按鈕。如果我在頁面加載中啓用它。該按鈕在每次回發或僅刷新後都會啓用。這裏z屏幕截圖的代碼迄今...使用Ajax計時器控件登錄錯誤後阻止用戶
protected void Button1_Click(object sender, EventArgs e)
{
en.Log_Username = TextBox1.Text;
en.Log_Password = TextBox2.Text;
dt = new DataTable();
dt = bll.log_Login(en);
if (dt.Rows.Count > 0)
{
Session["emp_Mobile"] = en.Log_Password;
Session["emp_Username"] = en.Log_Username;
Response.Redirect("Calling.aspx");
//Response.Redirect("Calling.aspx?emp_Mobile=" + Server.UrlEncode(en.Log_Password) + "&emp_Username=" + Server.UrlEncode(en.Log_Username));
}
else
{
Label1.Text = "Incorrect Username or Password";
int count = 0;
if (Session["incorrect"] != null)
{
count = Convert.ToInt32(Session["incorrect"]);
Session["incorrect"] = count + 1;
}
else
{
count = count + 1;
Session["incorrect"] = count;
}
if (count >2)
{
Label1.Text = "You've Entered Wrong Password 3 times, Please wait for sometime!";
Timer1_Tick(sender, e);
}
}
}
protected void Timer1_Tick(object sender, EventArgs e)
{
Button1.Enabled = false;
}
請將您的代碼發佈爲文本 – VladL
我通過從頁面加載中刪除Button1.Enabled來獲得它的工作。 唯一的事情是標籤現在不打印錯誤消息。 – Sunny