Tuesday, November 6, 2012

SharePoint DateTimeControl validation

Here i am explaining how to validate a sharepoint datetime control with asp.net required field validator.

Datetime control is a very easy to use but internally it is having a drawback of required validation property.

It has a property called IsRequiredField But it will not work for date format validation when you are working with Visual web parts or web parts.

For this we have to use classical ASP.NET required field validator to validate control

Internally the DateTimeControl of SharePoint is just a calendar dropdown and a text box. Also, they already implemented a simple required field validation by just using the IsRequiredField property.

However, if you try to put an asp.net validator (i.e.: CompareValidator, RegularExpressionValidtator, etc…) on it, it says it can’t find the control. This is happening because the DateTimeControl is just a wrapper around this textbox and if you set the Validator ControlToValidate property to the DateTimeControl it isn’t smart enough to know to really validate against the actual textbox

Here is the way you need to define


NOTE : Here ControlToValidate property you need to set as {DateControlID}${DateControlID}Date then only it will work otherwise it will through error

Thank you !!!


  1. Given so much information in it. its very useful .perfect explanation about Dot net framework.Thanks for your valuable information. dot net training in chennai velachery | dot net training institute in velachery

  2. It is really a great work and the way in which u r sharing the knowledge is excellent.Thanks for helping me to understand basic concepts. As a beginner in Dot Net programming your post help me a lot.Thanks for your informative article.. dot net training and placement in chennai | best dot net training in chennai