Solved

Easiest way to compare two textboxes have the same text?

Posted on 2009-04-15
5
196 Views
Last Modified: 2012-05-06
I have 2 textboxes:

Textbox1
Textbox2

The user must enter in values to both these texboxes but I need to ensure that the values entered into these textboxes match.

So what would be the simplest way to compare both these textboxes, without prompting a message box for every character entered.

I have tried doing it in the LostFocus Event and the TextChanged event. If there are any other recommendations I would love to hear them.

Cheers
0
Comment
Question by:directxBOB
5 Comments
 
LVL 19

Expert Comment

by:alb66
ID: 24148564
If in the page there is a button like "OK" or "Submit" or "Next", I'd check the values on the click event for that button
0
 

Author Comment

by:directxBOB
ID: 24148591
I have those checks in place, but the customer wants a realtime check while the user is focused on the two texboxes. The end user of this system would not be consider computer literate at all, nor do they care much for computers. So trying to get them to find a textbox/field to enter into could be a challenge.
0
 
LVL 16

Accepted Solution

by:
CuteBug earned 200 total points
ID: 24148634
You can also show a picturebox alongside TextBox2.
Handle the TextChangedEvent of the textboxes.
As long as the password doesn't match, show an error icon in the picturebox.
If the password match, show a green tick icon indicating that the passwords are matching.
0
 
LVL 19

Assisted Solution

by:alb66
alb66 earned 200 total points
ID: 24148637
In order to avoid message box while entering the text, you can display a static text (or an icon) near the text boxes while the two text are different. In this case you can do the compare in the TextChanged event
0
 

Assisted Solution

by:HuntedBounty
HuntedBounty earned 100 total points
ID: 24154819
why not make a button, and when its clicked it checks if the text boxes match?

if(textbox1.text == texbox2.text)
{
  // if both of these text boxes are equal then do something here
  messagebox.show("ok it works"); // you can change this to anything
}

hope this answers your question :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Aspnet xml 2 36
Unit testing, moq, best practices 7 28
Need help with a query 6 55
Iterate a dictionnary to change values 4 30
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now