Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6686093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:07:56+00:00 2026-05-26T05:07:56+00:00

I want to do some action if button clicked for 3 times. Just like

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:07:57+00:00Added an answer on May 26, 2026 at 5:07 am

    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

    1. Id,
    2. UserName,
    3. Password,
    4. LoginAttempt.

    And let’s say you have two TextBoxes on your Login.aspx page

    1. TextBoxUserName,
    2. TextBoxPassword.

    Let’s say you have one record in your TblUsers like this

    Id           : 1
    UserName     : rammstein
    Password     : ohnedich
    LoginAttempt : 0
    

    Now, you are in your Login.aspx.cs code

    you have a method and in it you have

    TblUsers user = new TblUsers();
    

    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

    UserName:rammstein 
    Password:duhast
    

    Checked your database with username rammstein and found it, and took that record in your TblpUsers user then you checked whether user.Password and TextBoxPassword.Text matches.Well it won’t match for the above example because

    user.Password is ohnedich however TextBox.Password is duhast.This means the login is not successfull so you set false to your bool login.

    Everything else belongs to the below code with if-else condition

    if(user.LoginAttempt < 3){
    
          if(!login)
          {
              user.LoginAttempt = user.LoginAttempt + 1;
          }
          else
          {
              user.LoginAttempt = 0;
          }
    }
    else
    {
      //do something
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a button which when clicked calls an action. I have
In a view, I want to consume some Json produced by an action on
I want my setup.py to do some custom actions besides just installing the Python
I want some of the goodies in a ListView, like being able to use
I want some like this: How make it ideologically correct?
I have some simple javascript that I'd like to run when a button is
I want to create an NSButton that sends an action when it is clicked,
If I want to fetch a form, then grab some button, then attach some
I do have a button and when this button is clicked I want to
I want some examples of C preprocessor directives, such as: #define pi 3.14 #define

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.