How to use Sharepoint default Datetimecontrol picker for custom application built in VS for Sharepoint 2007


In this article we will see that how to use sharepoint default datetimecontrol picker in custom webparts. I will show it in a .aspx but we can use it in the usercontrol and can make a custom webpart of that usercontrol.

Here are the steps to use the sharepoint datetimecontrol in custom application built in ASP.net

Step 1: Open Visual studio and create one Website.

1.gif
 
Step2:  Add the below mention Register tag in .ascx file.

<%@ Register TagPrefix="dtc" Namespace="Microsoft.SharePoint.WebControls"
             Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

2.gif
 
Step 3: After adding this Register tag add the below mentioned line in .ascx file

    <dtc:DateTimeControl ID = "dtcControl" runat = "server" ></dtc:DateTimeControl>

3.gif
 
Step 4: Build the website and place the Default.aspx and Default.aspx.cs files in the below mentioned location.

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\Test

Now open any website that you have already created. In my case I have already created one website with the url http://spdevserver:1003/

4.gif
 
Now just add "_layouts/test/Default.aspx" to the URL.

Now the url becomes http://spdevserver:1003/_layouts/test/Default.aspx

Click on GO button you will see the sharepoint datetime control picker.

5.gif
 
There are lots of default properties that you can use according to the requirements like if you don't want time part than just set the dateonly property to true.

6.gif
 
In this way we can use datetime control for the custom applications built for Sharepoint 2007. 

Hope this article will be a help to you.

Up Next
    Ebook Download
    View all
    Learn
    View all