Sharepoint Web Control - Validating date time control (SPDateTimeControl with validators)

When working with Sharepoint Controls you may experience different behavior sometime as anticipated with any other controls library. I was thinking of doing some date validation and found some interesting fact with SPDateTime Control.

Few were not relevant to me so I didnt looked up them but I need to put required field validator for my mandatory field. I noticed that required field validator included in libaray was not working. After looking at member properties I found that there are properties included in controls for handling this

1. IsRequiredField
2. ErrorMessage

I used above fields and it worked for me nicely. The second task was to control invlaid dates entry from user. I thought it would be built in in the control and my guess was right with some exception. Sharepoint was handling this but for some reason it was not controlled at client side. I checked SPDateTimeControl.IsValid at server side and it worked for me.

Though it was working on server side I decided to stop false entry at client side for better GUI. I placed regular expression validator but it was not workin again. I did some research and find a soloution fo it i.e in ControlToValidate property place [ControlName]$[ControlName]Date instead of control name and it will solve issue

Comments

Popular posts from this blog

Sharepoint 2007 Showing outlook Inbox using outlook active X control

IIS Configuration Error Error: Cannot write configuration file due to insufficient permissions

Java IDE for Grail Development