Okay, in my company we are converting a lot of ASP application to ASP .NET and C#. There is a convention that is used on form fields in the ASP pages. If a field is required, the field name is prefixed with an r. I was asked to adopt this methodology to .Net. So I have created a class that will perform validation on a given form. The methodology I adapted was to suffix my field names with an underscore and then list any subscripts necessary for validation.
So far the possible subscripts I have come up with are:
r - required
d - date
e - email
n - numeric
An example would be txtFirstName_r, for a text box control that is a required field. The subscripts can also be combined in any order that makes sense (i.e. you wouldn't want a field to have both a _d and n as that is contradictory) so you could have txtDateEntered_rd.
There is the obvious draw back of having only a maximum of 26 subscripts in addition to the fact that if I went sequentially through the alphabet, the subscript would have no intuitive correlation to its purpose.
Mind you this is only intended for simple and basic validations. Actual business validations would be accomplished through another means.
I will post the code I have for this shortly.
What I would like is a critique of this course of action. It seems like its pulling teeth whenever I go to find a method of validating my form that can be reused fairly easily with minimal changes.
As for the validation controls that come with .Net, they seem a crock and a gimmick and I would be surprised if they were ever used in any enterprise class sort of project. The amount of things that have to be redone on a page to page basis seems amazing. Furthermore, you get to do it all over again for the next project. If any one has issue with this, I would love to be corrected as my concern is far more than about simply being right. I just want a method of validating form input that is fairly simplistic and easily reusable.
Thanks for your time. I'll post my code within the hour.