I am having a problem with the AjaxControlToolkit CalendarExtender. Let me explain my page setup. I have an ASP TextBox on the page that is supposed to hold the End Time of an event. The time must be in the format "MM/dd/yyyy hh:mm:ss tt" (i.e. 11/06/2011 11:59:59 PM).
Here is what the page layout looks like:
A reference to the AjaxControlToolkit at the top of the page.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
The relevant body markup of the page:
<asp:Label ID="_lblEventEndTime" runat="server" Text="End Time:" />
<asp:TextBox ID="_txtEventEndTime" runat="server" />
<asp:ImageButton ID="_imgbtnEventEndTime" runat="server" ImageUrl="~/Images/Calendar.png"/>
<ajax:CalendarExtender ID="_cldrextEndDate" runat="server" PopupButtonID="_imgbtnEventEndTime" TargetControlID="_txtEventEndTime" Format="MM/dd/yyyy hh:mm:ss tt" />
And the C# code behind:
protected void Page_Load(object sender, EventArgs e)
{
DateTime nov6 = new DateTime(2011, 11, 6, 23, 59, 59);
_txtEventEndTime.Text = nov6.ToString("MM/dd/yyyy hh:mm:ss tt");
}
Now for some reason I have only been able to reproduce this bug on November 6, 2011. But as you can see in the on Page_Load I am setting the time to 23:59:59 which is 11:59:59 PM. However when the page comes back the textbox says "11/06/2011 10:59:59 PM" instead of "11/06/2011 11:59:59 PM"
Now here is where things get weird. If I remove the CalendarExtender from the page everything works fine and the page loads as expected with the correct value in the TextBox. What is also weird is if I change the FormatString of the CalendarExtender to
Format="MMMM/dd/yyyy hh:mm:ss tt"
the page loads with the proper value - the only problem here is now when I actually click my Calendar ImageButton and use the CalendarExtender it will place the DateTime into the TextBox in the format "November/06/2011 12:00:00 AM" (but this is expected).
Now if I change the DateTime in the code behind to
DateTime nov6 = new DateTime(2011, 11, 6, 22, 59, 59);
The Textbox will come back as "11/06/2011 09:59:59 PM" but it should read "11/06/2011 10:59:59 PM".
What I am perplexed about is why the CalendarExtender is interfering with my TextBox Control. Its almost as if the calendar extender things that hours go from 1-24 instead of 0-23. Is there some sort of bug with the CalendarExtender that I am not aware of?
P.S. - All of these controls are on a test page so there is nothing else interfering with them.
Here is what the page layout looks like:
A reference to the AjaxControlToolkit at the top of the page.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
The relevant body markup of the page:
<asp:Label ID="_lblEventEndTime" runat="server" Text="End Time:" />
<asp:TextBox ID="_txtEventEndTime" runat="server" />
<asp:ImageButton ID="_imgbtnEventEndTime" runat="server" ImageUrl="~/Images/Calendar.png"/>
<ajax:CalendarExtender ID="_cldrextEndDate" runat="server" PopupButtonID="_imgbtnEventEndTime" TargetControlID="_txtEventEndTime" Format="MM/dd/yyyy hh:mm:ss tt" />
And the C# code behind:
protected void Page_Load(object sender, EventArgs e)
{
DateTime nov6 = new DateTime(2011, 11, 6, 23, 59, 59);
_txtEventEndTime.Text = nov6.ToString("MM/dd/yyyy hh:mm:ss tt");
}
Now for some reason I have only been able to reproduce this bug on November 6, 2011. But as you can see in the on Page_Load I am setting the time to 23:59:59 which is 11:59:59 PM. However when the page comes back the textbox says "11/06/2011 10:59:59 PM" instead of "11/06/2011 11:59:59 PM"
Now here is where things get weird. If I remove the CalendarExtender from the page everything works fine and the page loads as expected with the correct value in the TextBox. What is also weird is if I change the FormatString of the CalendarExtender to
Format="MMMM/dd/yyyy hh:mm:ss tt"
the page loads with the proper value - the only problem here is now when I actually click my Calendar ImageButton and use the CalendarExtender it will place the DateTime into the TextBox in the format "November/06/2011 12:00:00 AM" (but this is expected).
Now if I change the DateTime in the code behind to
DateTime nov6 = new DateTime(2011, 11, 6, 22, 59, 59);
The Textbox will come back as "11/06/2011 09:59:59 PM" but it should read "11/06/2011 10:59:59 PM".
What I am perplexed about is why the CalendarExtender is interfering with my TextBox Control. Its almost as if the calendar extender things that hours go from 1-24 instead of 0-23. Is there some sort of bug with the CalendarExtender that I am not aware of?
P.S. - All of these controls are on a test page so there is nothing else interfering with them.