What´s the best way for validating input data?
-
I validate all input data using a Validation class with functions like: IsAlpha, IsAlphaNumeric, IsEmail, Lenght, IsNumber Normally I make the validation in the Click Event of a form, and then I show the errors using an error control. Is there a better way to validate input data? And for what are the events "Validated" and "Validating"? Thanks.
-
I validate all input data using a Validation class with functions like: IsAlpha, IsAlphaNumeric, IsEmail, Lenght, IsNumber Normally I make the validation in the Click Event of a form, and then I show the errors using an error control. Is there a better way to validate input data? And for what are the events "Validated" and "Validating"? Thanks.
hi, If you are talking about windows application then you have to write custom functions like what you mentioned. And you can provide ErrorProvider control for interactive error notification. You can encapsulate your custom error checking here in Validated event of your textbox controls. eg. private void TextBox1_Validated(object sender, System.EventArgs e) { if(IsValid()) { nameErrorProvider.SetError(this.TextBox1, ""); } else { // Set the error if the name is not valid. nameErrorProvider.SetError(this.TextBox1, "Name is required."); } } ;) ************************** S r e e j i t h N a i r **************************
-
hi, If you are talking about windows application then you have to write custom functions like what you mentioned. And you can provide ErrorProvider control for interactive error notification. You can encapsulate your custom error checking here in Validated event of your textbox controls. eg. private void TextBox1_Validated(object sender, System.EventArgs e) { if(IsValid()) { nameErrorProvider.SetError(this.TextBox1, ""); } else { // Set the error if the name is not valid. nameErrorProvider.SetError(this.TextBox1, "Name is required."); } } ;) ************************** S r e e j i t h N a i r **************************