• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

Validating event not being fired

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
rogaut1
Asked:
rogaut1
  • 2
1 Solution
 
rogaut1Author Commented:
and yes the CausesValidation property for txtUserid is set to true.
0
 
MattWareCommented:
What does the event handler code ok?

eg
this.object.event += new System.EventHandler(this.MethodName);
                  
0
 
rogaut1Author Commented:
That was the problem !   Thank you....the book I was reading never specified subcribing to the event.....




Thanks !


Robert
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now