I want to do some action if button clicked for 3 times. Just like if users enters a wrong password for 3 times the page the page must be redirected to another page or something.
How to do action in ASP.NET C# if button clicked for 3rd time?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’d use a session variable.
Another solution could be having a column in the users table named LoginAttempt(int)(default 0), how I would use that column is
Let’s say you have a table in your databese called TblUsers with these columns
And let’s say you have two TextBoxes on your Login.aspx page
TextBoxUserName,TextBoxPassword.Let’s say you have one record in your TblUsers like this
Now, you are in your Login.aspx.cs code
you have a method and in it you have
And you have a
bool login = false;.You’ve got the username from
TextBoxUserName.Text, you check if a user with this username exists then if it exist you do the below code.Let’s follow this scenerio
The given user tried to login with
Checked your database with username rammstein and found it, and took that record in your
TblpUsers userthen you checked whetheruser.PasswordandTextBoxPassword.Textmatches.Well it won’t match for the above example becauseuser.PasswordisohnedichhoweverTextBox.Passwordisduhast.This means the login is not successfull so you set false to yourbool login.Everything else belongs to the below code with
if-elsecondition