Development SharePoint:DateTimeControl – Check if control is empty

SharePoint offers a DateTime picker control that you can use in your web parts and application pages. This control has the name DateTimeControl and is located in the Microsoft.SharePoint.WebControls namespace of the Microsoft.SharePoint.dll.

You can place it on your application page as follows: <SharePoint:DateTimeControl
ID=”DateTimeControl1″ runat=”server”

After having added the required directive at the top of the page:

TagPrefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls”

Assembly=”Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c”



If you want to add the date picker control from code.

DateTimeControl datetimepicker;

void CreateChildControls()



datetimepicker = new

datetimepicker.ID = “datetimeControl1”;



// initialize other controls



If in your code you want to test if the user selected a date in the DateTimeControl, you have to use the IsDateEmpty property instead of the SelectedDate.

If the user didn’t enter a date, the SelectedDate property will return today’s date.

void Submit()


if (!datetimepicker.IsDateEmpty)


var selectedDate = datetimepicker.SelectedDate;


// continue your function




Sign up for our newsletter to stay up to
date with tech news!