Solved

Validating event not being fired

Posted on 2003-12-04
3
209 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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