Solved

Validating event not being fired

Posted on 2003-12-04
3
211 Views
Last Modified: 2010-04-16
I am using an error provider to validate a text box, my problem is the event is not being raised when I go to another field, why ?

Here is my code:

private void txtUserId_Validating(object sender, System.ComponentModel.CancelEventArgs e )
{
     string error = null;
     MessageBox.Show("What !");
     if ( this.txtUserId.Text.Length == 0 )
    {
        error = "The userid is a mandatory field, please enter a userid.";
       e.Cancel = true;
    }

   this.errorProvider1.SetError((Control) sender,error);
}
0
Comment
Question by:rogaut1
  • 2
3 Comments
 
LVL 2

Author Comment

by:rogaut1
ID: 9875373
and yes the CausesValidation property for txtUserid is set to true.
0
 
LVL 2

Accepted Solution

by:
MattWare earned 500 total points
ID: 9876848
What does the event handler code ok?

eg
this.object.event += new System.EventHandler(this.MethodName);
                  
0
 
LVL 2

Author Comment

by:rogaut1
ID: 9876949
That was the problem !   Thank you....the book I was reading never specified subcribing to the event.....




Thanks !


Robert
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 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