473,856 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disable TextBox When Enter worng Password 3 Times (C#)

29 New Member
hello

i have a program in c#

Expand|Select|Wrap|Line Numbers
  1. protected void Button1_Click(object sender, EventArgs e)
  2.     {
  3.         Datareader1 = MyCom1.ExecuteReader();
  4.         if (Datareader1.Read())
  5.         {
  6.             Datareader1.Close();
  7.             DataReader = MyCom.ExecuteReader();
  8.             if (DataReader.Read())
  9.             {
  10.                 Response.Redirect("Default.aspx?uname=" + TextBox1.Text);
  11.             }
  12.  
  13.             else
  14.             {
  15.                 MessageBox.Show("Password Is Wrong", "Wrong Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
  16.             }
  17.  
  18.         }
  19.         else
  20.         {
  21.             MessageBox.Show("UserName Is Not Found");
  22.  
  23.         }
  24.     }
I want to Disable The Password's TextBox If the User Enter A wrong password 3 times

i tried to do this with for but it didn't work

any help plz ?!
Mar 7 '07 #1
10 6761
radcaesar
759 Recognized Expert Contributor
Have a session variable and increment it when the password is wrong.

Disable the txtPassword (TextBox) when the session variable ==3

:)
Mar 7 '07 #2
MCPD
29 New Member
please can u explain more

becuase i am new and not professional

what mean session variable
Mar 7 '07 #3
MCPD
29 New Member
if u mean

Expand|Select|Wrap|Line Numbers
  1. Session ["abc"] =0;
i know that the session variable cant be increased

i cant do this

Expand|Select|Wrap|Line Numbers
  1. Session["abc"]+=1;
Mar 7 '07 #4
radcaesar
759 Recognized Expert Contributor
A Session variable retains the value until its destroyed or the browser is closed.

Refer ASP .NET tutors for more informations.

:)
Mar 7 '07 #5
MCPD
29 New Member
if u mean

Expand|Select|Wrap|Line Numbers
  1. Session ["abc"] =0;
i know that the session variable cant be increased

i cant do this

Expand|Select|Wrap|Line Numbers
  1. Session["abc"]+=1;
please read this
Mar 7 '07 #6
radcaesar
759 Recognized Expert Contributor
But i can do that

Session["LoginAttem pt"] = ((int) Session["LoginAttem pt"]) + 1;
return (int) Session["LoginAttem pt"];

Right ?????

:)
Mar 7 '07 #7
MCPD
29 New Member
it doesn't work man

i write this

Expand|Select|Wrap|Line Numbers
  1. protected void Button1_Click(object sender, EventArgs e)
  2.     {
  3.         Session["LoginAttempt"] = 0;
  4.         Datareader1 = MyCom1.ExecuteReader();
  5.         if (((int)Session["LoginAttempt"]) != 3)
  6.         {
  7.             if (Datareader1.Read())
  8.             {
  9.                 Datareader1.Close();
  10.                 DataReader = MyCom.ExecuteReader();
  11.                 if (DataReader.Read())
  12.                 {
  13.                     Response.Redirect("Default.aspx?uname=" + TextBox1.Text);
  14.                 }
  15.  
  16.                 else
  17.                 {
  18.                     MessageBox.Show("Password Is Wrong", "Wrong Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
  19.                     Session["LoginAttempt"] = ((int)Session["LoginAttempt"]) + 1;
  20.                 }
  21.  
  22.             }
  23.             else
  24.             {
  25.                 MessageBox.Show("UserName Is Not Found");
  26.  
  27.             }
  28.         }
  29.         else
  30.         {
  31.             MessageBox.Show("You Login Faild");
  32.             TextBox2.Enabled = false;
  33.         }
  34.         }
  35.  
  36.     }
Mar 7 '07 #8
radcaesar
759 Recognized Expert Contributor
Debug this code line by line. It never works, if you approach like this.

What that mean
if (Datareader1.Re ad()) ?

Debug and check whether it searches for correct username and password.

:)

it doesn't work man

i write this



Expand|Select|Wrap|Line Numbers
  1. protected void Button1_Click(object sender, EventArgs e)
  2.     {
  3.         Session["LoginAttempt"] = 0;
  4.         Datareader1 = MyCom1.ExecuteReader();
  5.         if (((int)Session["LoginAttempt"]) != 3)
  6.         {
  7.             if (Datareader1.Read())
  8.             {
  9.                 Datareader1.Close();
  10.                 DataReader = MyCom.ExecuteReader();
  11.                 if (DataReader.Read())
  12.                 {
  13.                     Response.Redirect("Default.aspx?uname=" + TextBox1.Text);
  14.                 }
  15.  
  16.                 else
  17.                 {
  18.                     MessageBox.Show("Password Is Wrong", "Wrong Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
  19.                     Session["LoginAttempt"] = ((int)Session["LoginAttempt"]) + 1;
  20.                 }
  21.  
  22.             }
  23.             else
  24.             {
  25.                 MessageBox.Show("UserName Is Not Found");
  26.  
  27.             }
  28.         }
  29.         else
  30.         {
  31.             MessageBox.Show("You Login Faild");
  32.             TextBox2.Enabled = false;
  33.         }
  34.         }
  35.  
  36.     }
Mar 7 '07 #9
MCPD
29 New Member
DataReader.Read () thats my datareader
and it check if the command is return something from the sql
and this is what containt the datareader1

Datareader1 = MyCom1.ExecuteR eader();

And MyCom1 Is

MyCom1 = new SqlCommand("sel ect * from Users where UserName='" + TextBox1.Text + "'", MyCon);
Mar 7 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5041
by: Derek White | last post by:
Ok here's the deal. We are finally getting DSL again... but our PC is in the living room... and the youngest has figured out that if he hits the right keys... he can bring up Internet Explorer. All is fine and dandy right now, but come next week... that things wont be so dandy. I am setting our LInux router/server back up soon, and would like a quick, easy way to enable and disable our internet access. What I would like to do is have...
4
2090
by: Paul T. RONG | last post by:
Dear All, I add two new tables to the database and then the disable shift key codes don't work. These two new tables are actually created by two queries, and only these two are in the front end, I didn't manage to move them to the back end. I work with Access 2k under Win XP. these are the codes that don't work (it worked for more than a year very well):
13
14588
by: Rich | last post by:
Hello, So I would like to disable a textbox on a vb.net form without the text getting grayed out. In vb6 I could place a textbox control on a frame control and disable the frame leaving the textbox enabled and text/background were intact but mouse cursor remained an arraw (as opposed to an I for editable). I tried a Panel control on my .net form since I could I guess there is no longer a frame control (also tried a groupbox control)....
1
1022
by: Greg Smith | last post by:
How do you hold the data in a password TextBox on a PostBack? My users don't like it if enter data into the password and password confirm Textbox and another control's PostBack clears it out. Any help is greatly appreciated.
6
17795
by: =?Utf-8?B?TWljaGFlbCAwMw==?= | last post by:
I need to disable the clipboard function in Windows XP. We are having a problem with users using CTRL+C in one program, then using CTRL+V in another. Specifically, they type their password into notepad, copy it to the clipboard, then paste it in another program. The other program runs on Windows XP. Obviously, the correct answer is to have the creators of the other program to disable pasting in a password field, but they are reluctant...
0
2407
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile View I want the form populated from there profile on the sql server. The code to save the profile works fine. But when the user logs back in they data doesn't load back to the form. The multiview is located inside the LoginView's Logged-In View ....
1
2386
by: robin1983 | last post by:
Dear All, I got stuck in simple problem, I have a two php file one for registration form and one for to check and insert into the table. The problem is that when I get any kind error in validiation the code is working properly but when the condition are fulfilled the code inside the if part is not executing. The following is the code for registration form UserAdd.php <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
2
3732
by: jd | last post by:
I have several textboxes in which the end user can enter values. When the user presses the Enter key when in any of the textboxes, or leaves that textbox, I want a routine to run (mathematical analysis followed by plotting a graph). Since it is relatively slow (less than a second, but makes the updating sluggish) I only want it to be triggered when the value in one of the textboxes is actually changed by the user - pressing Enter or leaving...
10
6988
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
9760
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11052
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10695
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10777
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7930
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7090
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5759
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4573
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4172
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.