0
votes

I have implemented the SharePoint:DateTimeControl in a very simple webpart

<SharePoint:DateTimeControl ID="dtStartdate" runat="server" DateOnly="true" />

The problem is when I click on the control it renders an exception

Server Error in '/' Application.
Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 
[NullReferenceException: Object reference not set to an instance of an object.]
   Microsoft.SharePoint.Utilities.SPUtility.GetThemedImageUrl(String originalUrl, String themeKey) +199
   Microsoft.SharePoint.WebControls.DatePicker..ctor() +1460
   Microsoft.SharePoint.WebControls.SPDatePickerControl.InitDatePicker() +44
   Microsoft.SharePoint.WebControls.SPDatePickerControl.set_MinJDay(Int32 value) +25
   Microsoft.SharePoint.ApplicationPages.DatePickerFrame.Page_Load(Object sender, EventArgs e) +1708
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.LoadRecursive() +94
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2935

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

enter image description here

Any advice or help to resolve this is highly appreciated, thanks!

1

1 Answers

1
votes

I know it's been a while since you asked this but having just solved something very similar I thought I'd share my (simple) solution.

Make sure you have a site collection created at the root of the web app.

I was working on a web part in http: //webapp/sites/mysitecollection and had the above error. Looking at http: //webapp gave me a 404 so I created a root site collection and now the datepicker in my sitecollection works fine.