SharePoint Date Time Control validation

What if you would need to validate date time control in a visual web part ? Yes , its very simple. You need to use compare validator to validate the SharePoint date time control. The code is given below.
 

<sharePoint:DateTimeControl ID="dteJoining" runat="server" DateOnly="true" /> 
<asp:CompareValidator id="validateDate" runat="server"
        ControlToValidate="dteJoining$dteJoiningDate" 
     Type="Date" Operator="DataTypeCheck" ErrorMessage="Please enter an valid date">  </asp:CompareValidator >

The following properties can be validated against
 
•DateOnly
•IsRequiredField
•MinDate
•MaxDate
 
Happy Share Pointing :-)
 
 
Ebook Download
View all
Learn
View all