void IPostBackEventHandler.RaisePostBackEvent(string arg) #endif { #if NET_2_0 ValidateEvent(UniqueID, arg); #endif if (arg.Length < 1) { return; } if (arg[0] == 'V') // Goes to Next or Previous month { DateTime prev = VisibleDate; int days = Int32.Parse(arg.Substring(1)); DateTime dt = GetGlobalCalendar().AddDays(dateZenith, days); VisibleDate = dt; OnVisibleMonthChanged(VisibleDate, prev); return; } if (arg[0] == 'R') // Selects a range of dates { string num, date, days; num = arg.Substring(1); days = num.Substring(num.Length - 2, 2); date = num.Substring(0, num.Length - 2); DateTime d = GetGlobalCalendar().AddDays(dateZenith, Int32.Parse(date)); SelectedDates.SelectRange(d, d.AddDays(Int32.Parse(days))); OnSelectionChanged(); return; } // Selects a single day int daysFromZenith = Int32.Parse(arg); DateTime day = GetGlobalCalendar().AddDays(dateZenith, daysFromZenith); SelectedDates.SelectRange(day, day); OnSelectionChanged(); }
protected virtual void RaisePostBackEvent(string eventArgument) { ValidateEvent(UniqueID, eventArgument); if (eventArgument.Length < 1) { return; } if (eventArgument[0] == 'V') // Goes to Next or Previous month { DateTime prev = VisibleDate; int days = Int32.Parse(eventArgument.Substring(1)); DateTime dt = GetGlobalCalendar().AddDays(dateZenith, days); VisibleDate = dt; OnVisibleMonthChanged(VisibleDate, prev); return; } if (eventArgument[0] == 'R') // Selects a range of dates { string num, date, days; num = eventArgument.Substring(1); days = num.Substring(num.Length - 2, 2); date = num.Substring(0, num.Length - 2); DateTime d = GetGlobalCalendar().AddDays(dateZenith, Int32.Parse(date)); SelectedDates.SelectRange(d, d.AddDays(Int32.Parse(days))); OnSelectionChanged(); return; } // Selects a single day int daysFromZenith = Int32.Parse(eventArgument); DateTime day = GetGlobalCalendar().AddDays(dateZenith, daysFromZenith); SelectedDates.SelectRange(day, day); OnSelectionChanged(); }
// ==================================================================== // Implementation of the IPostBackEventHandler.RaisePostBackEvent // event handler. // ==================================================================== /// <summary> /// Handles a post back event targeted at the control. /// </summary> /// <param name="eventArgument"> /// A <see cref="System.String" /> representing the event argument passed to the handler. /// </param> public new void RaisePostBackEvent(string eventArgument) { // Was the post back initiated by a previous or next month link if (eventArgument.StartsWith("V")) { try { // Save the current visible date. var previousDate = TargetDate; // Extract the day count from the argument and use it to // change the visible date. var d = int.Parse(eventArgument.Substring(1)); VisibleDate = DateFromDayCount(d); // Raise the VisibleMonthChanged event. OnVisibleMonthChanged(VisibleDate, previousDate); } // ReSharper disable once EmptyGeneralCatchClause catch (Exception) { } return; } // Was the post back initiated by a month or week selector link if (eventArgument.StartsWith("R")) { try { // Extract the day count and number of days from the // argument. var d = int.Parse(eventArgument.Substring(1, eventArgument.Length - 3)); var n = int.Parse(eventArgument.Substring(eventArgument.Length - 2)); // Get the starting date. var date = DateFromDayCount(d); // Reset the selected dates collection to include all the // dates in the given range. SelectedDates.Clear(); SelectedDates.SelectRange(date, date.AddDays(n - 1)); // // If SelectAllInRange is false, remove any dates found // // in the nonselectable date list. // if (!this.SelectAllInRange) // { // ArrayList nonselectableDates = this.LoadNonselectableDates(); // foreach(DateTime badDate in nonselectableDates) // this.SelectedDates.Remove(badDate); // } // Raise the SelectionChanged event. OnSelectionChanged(); } catch (Exception) { } return; } // The post back must have been initiated by a calendar day link. try { // Get the day count from the argument. var d = int.Parse(eventArgument); // Reset the selected dates collection to include only the // newly selected date. SelectedDates.Clear(); SelectedDates.Add(DateFromDayCount(d)); // Raise the SelectionChanged event. OnSelectionChanged(); } catch (Exception) { } }