Guest User

Untitled

a guest
Aug 1st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. How to disable the Submit Button for a given duration?
  2. protected void Button1_Click(object sender, EventArgs e)
  3. {
  4. int count = 0;
  5. string username = TextBox1.Text.Trim();
  6. string password = TextBox2.Text.Trim();
  7. String connString = ConfigurationManager.ConnectionStrings["Myconnection"].ToString();
  8. SqlConnection conn = new SqlConnection(connString);
  9. SqlCommand cmd = new SqlCommand("Login", conn);
  10. cmd.CommandType = CommandType.StoredProcedure;
  11. cmd.Parameters.AddWithValue("@username", username);
  12. cmd.Parameters.AddWithValue("@password", password);
  13. conn.Open();
  14. SqlDataReader read = cmd.ExecuteReader();
  15. read.Read();
  16.  
  17. if (read.HasRows)
  18. {
  19. Session["LoggedIn"] = "correct";
  20. Response.Redirect("WebForm2.aspx", false);
  21. }
  22. else
  23. {
  24. Label1.Visible = true;
  25. Label1.Text = "Wrong user/password";
  26. conn.Close();
  27. }
  28.  
  29. if (System.Convert.ToInt32(ViewState["Tries"]) == 2)
  30. {
  31. Label1.Text = "Exceeded 3 times Attempts.Please Login after some time";
  32. TextBox1.Enabled = false;
  33. TextBox2.Enabled = false;
  34. Button1.Enabled = false; // Button1 is the submit button
  35. }
  36. else
  37. {
  38. // Otherwise, increment number of tries.
  39. ViewState["Tries"] = System.Convert.ToInt32(ViewState["Tries"]) + 1;
  40. if (System.Convert.ToInt32(ViewState["Tries"]) == 2)
  41. Label1.Text = "Exceeded 3 times Attempts.Please Login after some time";
  42. }
  43. }
  44.  
  45. LockingTime
  46.  
  47. Userid LockTime LockedDateTime
  48. 1 30 01/03/2012 12:30
  49.  
  50. UserId = id of the user locked
  51. LockTime - amount of time user Get locked
  52. LockDateTime - DateTime when user account locked
Add Comment
Please, Sign In to add comment