Link to home
Start Free TrialLog in
Avatar of rogaut1
rogaut1

asked on

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);
}
Avatar of rogaut1
rogaut1

ASKER

and yes the CausesValidation property for txtUserid is set to true.
ASKER CERTIFIED SOLUTION
Avatar of MattWare
MattWare

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rogaut1

ASKER

That was the problem !   Thank you....the book I was reading never specified subcribing to the event.....




Thanks !


Robert