我有一个使用Daypilot pro(7.9)和ajaxtoolkit:CalendarExtender的站点(.Net)。 它用于在Dynamics中预订日期,它就像一个魅力UNTIL我选择2016年的日期...当我选择2016年的日期或周数时,日历会跳回到所选周的前一周。我使用的是瑞典格式,我唯一的线索是,2015年有53周,而日常驾驶员可能会对此感到困惑吗?
这是代码(日期时间选择器来自ajaxtoolkit)
<div id="divCalendar" runat="server" style="float: left; width: 90px; height:25px; margin-top: 2px;">
<ajaxToolKit:CalendarExtender ID="calendar" runat="server" TargetControlID="dateTimeTextBox"
Format="yyyy-MM-dd" PopupButtonID="popupButton" firstDayOfWeek="Monday" />
<asp:TextBox ID="dateTimeTextBox" runat="server" CssClass="inputfields" Width="80px" AutoPostBack="true"
OnTextChanged="DateTime_Changed" />
<asp:CompareValidator ID="dateTimeTextBoxFormat" runat="server" ControlToValidate="dateTimeTextBox"
Operator="DataTypeCheck" Type="Date" ErrorMessage="yyyy-mm-dd." Display="Dynamic"
ValidationGroup="DateTime" />
<asp:RequiredFieldValidator ID="dateTimeTextBoxRequired" runat="server" ControlToValidate="dateTimeTextBox"
ErrorMessage="*" Display="Dynamic" ValidationGroup="DateTime" />
</div>
<div id="divCalendarButton" runat="server" style="float: left; width: 39px; margin-right: 12px;">
<asp:Image ID="popupButton" runat="server" ImageUrl="/_imgs/btn_on_cal.gif" Style="cursor: pointer; height: 25px; padding-top: 3px;" />
</div>
<div id="divTime" runat="server" style="margin-left: 7px; padding-top: 3px;">
<asp:DropDownList ID="dropDownHours" runat="server" AutoPostBack="true" />
<asp:DropDownList ID="dropDownMinutes" runat="server" AutoPostBack="true" />
</div>
这是DayPilot部分:
<div style="float: left; padding: 5px;">
<DayPilot:DayPilotCalendar ID="dayPilotCalendar" runat="server" DataStartField="Start"
DataEndField="End" DataTextField="Name" DataValueField="Id" DataTagFields="ActivityTypeName, ColorCode, Status"
BusinessBeginsHour="8" BusinessEndsHour="18" CellDuration="15" CellHeight="13"
HeightSpec="BusinessHours" ShowAllDayEvents="true" AllDayEnd="Date" ShowAllDayEventStartEnd="false"
EventClickHandling="JavaScript" EventClickJavaScript="viewEvent(e);" EventDoubleClickHandling="JavaScript"
EventDoubleClickJavaScript="editEvent(e);" DataAllDayField="WholeDayActivity"
TimeRangeSelectedHandling="JavaScript" TimeRangeSelectedJavaScript="createEvent(start, end, resource);"
TimeRangeDoubleClickHandling="JavaScript" TimeRangeDoubleClickJavaScript="createEvent(start, end, resource);"
ContextMenuID="DayPilotMenuActivity" OnBeforeEventRender="OnBeforeEventRender"
BubbleID="ActivityCalendarBubble" ShowToolTip="false">
</DayPilot:DayPilotCalendar>
我希望有人可以帮我找到解决方法。客户感到恼火,他们必须选择他们想要在日历中打开的那一周= P
答案 0 :(得分:0)
丹,这就是问题所在。 我从办公室里的英雄那里得到了帮助,帮助我把正确的约会给了.StartDate!
我们改变了这个:
public static DateTime GetDateFromWeekNumber(int year, int weekNumber)
{
DateTime date = new DateTime(year, 1, 1);
date = date.AddDays(7 * (weekNumber - 1));
date = date.AddDays(-(int)date.DayOfWeek + 1);
return date;
}
对此:
public static DateTime GetFirstDayOfWeek(DateTime dayInWeek)
{
CultureInfo cultureInfo = CultureInfo.CurrentCulture;
DayOfWeek firstDay = cultureInfo.DateTimeFormat.FirstDayOfWeek;
DateTime firstDayInWeek = dayInWeek.Date;
while (firstDayInWeek.DayOfWeek != firstDay)
firstDayInWeek = firstDayInWeek.AddDays(-1);
return firstDayInWeek;
}
现在它充当了魅力!没有Daypilot,只是旧代码= D