.NET validation controls and custom web control

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
 
P

Peter Blum

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
 
M

Marc Robitaille

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top