DateTimeControl is defined in the SharePoint WebControls class as the other controls in this post series.
Working with the DataTimeControl is fairly straight forward, with a few gotcha’s.
In my class, I have a Controls region with:
private DateTimeControl expirationDate;
In my CreateChildControls() override,
expirationDate = new DateTimeControl();
expirationDate.ID = “expirationDate”;
//We only want to capture the date, we can ignore the time
expirationDate.DateOnly = true;
Controls.Add(expirationDate);
Now, when I am checking the value of this control, there are two things to note, the SelectedDate field contains my data, BUT it is always set to Today! You have to do one other thing…
if (!expirationDate.IsDateEmpty)
{
//Now we can update our list item
listItem[“expirationDate”] = expirationDate.SelectedDate;
…
Well, that was a pretty easy one, but a couple of these steps can save you a lot of time. Enjoy!
A link to the MSDN site for this object is here.