Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 09, 2006 05:05 PM by PLBlum
Jan 08, 2006 10:26 AM|LINK
i just writed a custom validator who can validate a textbox on a date , so the input is only a date
but it doesn't work [:S] ,what is my problem
ctrl = FindControl(ControlToValidate);
then i compile the dll en add a reference from my website library to the dll
in my masterpage :
when i enter a incorrect value like "fffff" , the validator doesn't do his job and it fails in my code
what is the problem?
Jan 09, 2006 05:03 PM|LINK
Jan 09, 2006 05:05 PM|LINK
Anytime you pass an illegal string format into a Parse() method, expect it to throw an exception describing a formatting problem. You should anticipate this by either catching the exception or validating it prior to this point.
If I was to guess, you were expecting the validator to validate and stop the code in Register.aspx.cs from running. If that's the case, you didn't put the required line
// code to save or use the data.
For more on validators, see http://aspalliance.com/699.
In addition, ASP.NET comes with a validator to validate dates. Its the CompareValidator, with type=Date and Operator=DataTypeCheck. That article discusses this near the end.