.NET validation controls and custom web control

  • Thread starter Thread starter Marc Robitaille
  • Start date Start date
M

Marc Robitaille

Hello,

I built myself a calendar control. I want the control to be able to be
validated by .NET validation controls. So I added the
ValidationPropertyAttribute("Text") to my class declaration of my calendar
control. It is the Text property of my control which must be validated. I
add a CompareValidator control to my web page and I adjust the properties of
this control to validate my calendar control. I use a CompareValidator to
ensure me that it is well a date which is seized in my control. When I
seized a date, that seems to function but if I seized anything other that a
date, the error message of the compareValidator is not showing on my web
page. What do I have to do so my calendar control can be validated by .NET
validation controls?

excuse my bad english :-)
Thank you
 
By design, the CompareValidator will not evaluate when the ControlToValidate
returns an empty string. Most likely, when there is no selection on your
calendar, you are returning this. Its a good idea to return the empty
string. So leave that alone. Instead, add the RequiredFieldValidator just
like you would for an ordinary textbox.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
I have allready try this. If I enter 2005-12-31, it is ok. If I enter
2005-12-49, the error message of the validatoir doesn't show on the web
page. What do I have to do to make my control validate by a .NET validator
object?

p.s.
I have allready add the ValidationPropertyAttribute attribute to my class.

Marc R.
 
Back
Top