SharePoint Learning
Login
Signup Free
User Login
Close
 
 
Keep me logged in on this computer
Signup for a FREE user account
Close
Email
Password
Designation (optional)
First Name
Last Name
Headline (optional)
Online SharePoint training videos and articles
Price: FREE

SharePoint Development: DateTimeControl

By Lin Zhang on 05 June 14

This article shows you how to use the "DateTimeControl" in SharePoint Development

Add the following directive at the top of the page first:

<%@ Register TagPrefix="spuc" Namespace="Microsoft.SharePoint.WebControls"

             Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

You can then use the following on your page:

<spuc:DateTimeControl runat="server" ID="DateTimePickerControl1" />

You can add DateOnly or TimeOnly attribute to the control;
You can also set LocaleId="3081" if you are in Australia or LocaleId="2057" if you are in the UK so that the date format is "dd/MM/yyyy" instead of "MM/dd/yyyy".
To get the selected date in Code Behind:

DateTimePickerControl1.SelectedDate

To check if date is empty:

DateTimePickerControl1.IsDateEmpty

To Clear the selection:

DateTimePickerControl1.ClearSelection();

 

Comments:

No comments.

Copyright © SharePointLearning.net.au. All Rights Reserved | Contact Us

Powered by DigiLife Studio