Question

I have this application page with the following (simplified) markup:

<%@ Page Strict="true"  EnableViewState="true" Language="vb" MasterPageFile="~/_layouts/application.master" Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" %>

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"    Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" src="~/_controltemplates/InputFormSection.ascx" %> 
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" src="~/_controltemplates/ButtonSection.ascx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderMain" runat="server" OnDemand="True" >

<SharePoint:ScriptLink Language="javascript" Name="DatePicker.js" Localizable="False" runat="server"/> 

<SharePoint:SPDatePickerControl ID="MyDate" runat="server"  LocaleId="1033" TimeZone="0" >
</SharePoint:SPDatePickerControl> 

</asp:Content>

Essentially all that is on the page is a single control SPDatePickerControl and a ScriptLink control as the SPDatePickerControl requires DatePicker.js otherwise a JS error occurs.

When I click the left and right buttons to change the month (starting from November 2011), I see this odd behaviour:

  1. Clicking the left arrow takes me to October 2011.
  2. Clicking left again takes me back to November 2011.

  3. Clicking the Right arrow takes me to December 2011

  4. Clicking right again takes me to January 2012
  5. Clicking right again takes me to February 2012
  6. Clicking right again takes me back to November 2011.

Why? This seems very odd behaviour that I can't work out. Note that I have no code to check for postbacks at this point. Any ideas anyone?

Was it helpful?

Solution

I managed to find an answer…

After some ‘playing’ I noticed that there are two attributes that control this behaviour. They are:

StartOffset and EndOffset.

According to the SDK we have these:

StartOffset

[BindableAttribute(true)] 
[DefaultValueAttribute(-1)] 
[CategoryAttribute("Picker")] 
[DescriptionAttribute("Value betweeen -12 and 0")] 
public int StartOffset { get; set; }

EndOffset

[Bin dableAttribute(true)] 
[DefaultValueAttribute(3)] 
[DescriptionAttribute("Value betweeen 0 and 12")] 
[CategoryAttribute("Picker")] 
public int EndOffset { get; set; }

As you can see from the above, if you don’t set these, then they default to -1 and 3 for StartOffset and EndOffset respectively. This explains the odd behaviour I experienced. So my markup becomes:

<SharePoint:SPDatePickerControl StartOffset="-12" EndOffset="12" ID="MyDate" runat="server" LocaleId="1033" ></SharePoint:SPDatePickerControl>

This gives me 12 months in either direction until the cyclic behaviour appears back to November 2011. Hopefully this answer will help someone else.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top