Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CustomValidator - Making it do more.. 1

Status
Not open for further replies.

DSect

Programmer
Joined
Sep 3, 2001
Messages
191
Location
US
Hello -

I'm new to ASP.NET and I like the validation controls.

But -

I would like to use the CustomValidator to check for string length.

Problem:

Say I have 6 text boxes, all requiring validation restricting string lengths.

If I use the CustomValidator as is, I am limited to providing only the function to validate with and no additional arguments.

I would like use a ValidateStringLength function and pass it the max length of the string / control that's being validated.

I've seen messages on other boards that says I can't pass an additional argument to my validation function and someone suggested that a user create a new instance on the BaseValidator or CustomValidator that allows that functionality.

Anyone here ever do that or have examples of how it's done (creating a truly custom validator)?

Again - I would just like to be able to add an argument / variable that tell what length the maximum char. count is in a control that's validated by the CustomValidator
 
Thanks, Boulder.

I've resorted to using RegEx for right now, but this will come in handy when extending the BaseValidator..


 
Oops! Don't use that one. I optimized the code a bit. Let me see if I can dig it up.
 
Actually, I suspect the thread was probably pulled because I added a copyright symbol to it (to make sure no one just pulled the code and tried to sell the component as their own).

I don't mind if you use it for free, though, should you decide to in the future. If you want me to mail you the file you can drop me a note. My msn.com e-mail address is like my user name Boulder_Bum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top