Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to disable the Submit Button for a given duration?
- protected void Button1_Click(object sender, EventArgs e)
- {
- int count = 0;
- string username = TextBox1.Text.Trim();
- string password = TextBox2.Text.Trim();
- String connString = ConfigurationManager.ConnectionStrings["Myconnection"].ToString();
- SqlConnection conn = new SqlConnection(connString);
- SqlCommand cmd = new SqlCommand("Login", conn);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@username", username);
- cmd.Parameters.AddWithValue("@password", password);
- conn.Open();
- SqlDataReader read = cmd.ExecuteReader();
- read.Read();
- if (read.HasRows)
- {
- Session["LoggedIn"] = "correct";
- Response.Redirect("WebForm2.aspx", false);
- }
- else
- {
- Label1.Visible = true;
- Label1.Text = "Wrong user/password";
- conn.Close();
- }
- if (System.Convert.ToInt32(ViewState["Tries"]) == 2)
- {
- Label1.Text = "Exceeded 3 times Attempts.Please Login after some time";
- TextBox1.Enabled = false;
- TextBox2.Enabled = false;
- Button1.Enabled = false; // Button1 is the submit button
- }
- else
- {
- // Otherwise, increment number of tries.
- ViewState["Tries"] = System.Convert.ToInt32(ViewState["Tries"]) + 1;
- if (System.Convert.ToInt32(ViewState["Tries"]) == 2)
- Label1.Text = "Exceeded 3 times Attempts.Please Login after some time";
- }
- }
- LockingTime
- Userid LockTime LockedDateTime
- 1 30 01/03/2012 12:30
- UserId = id of the user locked
- LockTime - amount of time user Get locked
- LockDateTime - DateTime when user account locked
Add Comment
Please, Sign In to add comment