public static ViewStateMode GetAjaxViewStateFromWebConfig(ISite site) { ViewStateMode mode = ViewStateMode.Default; GlobalConfig config = GetCooliteSection(site); if (config != null) { mode = config.AjaxViewStateMode; } return(mode); }
public static ViewStateMode GetAjaxViewStateFromWebConfig(ISite site) { ViewStateMode mode = ViewStateMode.Inherit; GlobalConfig config = GetExtNetSection(site); if (config != null) { mode = config.AjaxViewStateMode; } return(mode); }
// Answer any state this control or its descendants want to save on freeze. // The format for saving is Triplet(myState, ArrayList childIDs, ArrayList childStates), // where myState or childStates and childIDs may be null. internal object SaveViewStateRecursive(ViewStateMode inheritedMode) { if (flags[disableViewState]) return null; bool saveThisState; if (flags[viewStateNotInherited]) { if (flags[viewStateMode]) { saveThisState = true; inheritedMode = ViewStateMode.Enabled; } else { saveThisState = false; inheritedMode = ViewStateMode.Disabled; } } else { saveThisState = (inheritedMode == ViewStateMode.Enabled); } object adapterState = null; object controlSavedState = null; if (saveThisState) { if (AdapterInternal != null) { adapterState = AdapterInternal.SaveAdapterViewState(); } controlSavedState = SaveViewState(); } ArrayList childStates = null; if (HasControls()) { ControlCollection occasionalFieldControls = _controls; int occasionalFieldControlCount = occasionalFieldControls.Count; bool useId = LoadViewStateByID; for (int i = 0; i < occasionalFieldControlCount; i++) { Control child = occasionalFieldControls[i]; object childState = child.SaveViewStateRecursive(inheritedMode); if (childState != null) { if (childStates == null) { childStates = new ArrayList(occasionalFieldControlCount); } if (useId) { child.EnsureID(); childStates.Add(child.ID); } else { childStates.Add(i); } childStates.Add(childState); } } } if (AdapterInternal != null) { if ((controlSavedState != null) || (adapterState != null) || (childStates != null)) { return new Triplet(controlSavedState, adapterState, childStates); } } else { if ((controlSavedState != null) || (childStates != null)) { return new Pair(controlSavedState, childStates); } } return null; }
public Control () { stateMask = ENABLE_VIEWSTATE | VISIBLE | AUTOID | BINDING_CONTAINER | AUTO_EVENT_WIREUP; if (this is INamingContainer) stateMask |= IS_NAMING_CONTAINER; #if NET_4_0 viewStateMode = ViewStateMode.Inherit; #endif }
/// <summary> /// Populates the roster. /// In cases where there won't be a postback, we can disable view state. The only time we need viewstate is when the Configuration Dialog /// is showing. /// </summary> private void PopulateRoster(ViewStateMode viewStateMode = ViewStateMode.Disabled) { RosterConfiguration rosterConfiguration = this.GetBlockUserPreference(UserPreferenceKey.RosterConfigurationJSON) .FromJsonOrNull <RosterConfiguration>() ?? new RosterConfiguration(); if (!rosterConfiguration.IsConfigured()) { return; } int[] scheduleIds = rosterConfiguration.ScheduleIds; int[] locationIds = rosterConfiguration.LocationIds; List <int> pickedGroupIds = rosterConfiguration.PickedGroupIds.ToList(); var allGroupIds = new List <int>(); allGroupIds.AddRange(pickedGroupIds); var rockContext = new RockContext(); // Only use teh ShowChildGroups option when there is 1 group selected if (rosterConfiguration.IncludeChildGroups && pickedGroupIds.Count == 1) { // if there is exactly one groupId we can avoid a 'Contains' (Contains has a small performance impact) var parentGroupId = pickedGroupIds[0]; var groupService = new GroupService(rockContext); // just the first level of child groups, not all decendants var childGroupIds = groupService.Queryable().Where(a => a.ParentGroupId == parentGroupId).Select(a => a.Id).ToList(); allGroupIds.AddRange(childGroupIds); } allGroupIds = allGroupIds.Distinct().ToList(); var attendanceOccurrenceService = new AttendanceOccurrenceService(rockContext); // An OccurrenceDate probably won't be included in the URL, but just in case DateTime?occurrenceDate = this.PageParameter(PageParameterKey.OccurrenceDate).AsDateTime(); if (!occurrenceDate.HasValue) { occurrenceDate = RockDateTime.Today; } // only show occurrences for the current day var attendanceOccurrenceQuery = attendanceOccurrenceService .Queryable() .Where(a => a.ScheduleId.HasValue && a.LocationId.HasValue && a.GroupId.HasValue) .WhereDeducedIsActive() .Where(a => allGroupIds.Contains(a.GroupId.Value) && a.OccurrenceDate == occurrenceDate && scheduleIds.Contains(a.ScheduleId.Value)); // if specific locations are specified, use those, otherwise just show all if (locationIds.Any()) { attendanceOccurrenceQuery = attendanceOccurrenceQuery.Where(a => locationIds.Contains(a.LocationId.Value)); } // limit attendees to ones that schedules (or are checked-in regardless of being scheduled) var confirmedAttendancesForOccurrenceQuery = attendanceOccurrenceQuery .SelectMany(a => a.Attendees) .Include(a => a.PersonAlias.Person) .Include(a => a.Occurrence.Group.Members) .WhereScheduledOrCheckedIn(); var confirmedScheduledIndividualsForOccurrenceId = confirmedAttendancesForOccurrenceQuery .AsNoTracking() .ToList() .GroupBy(a => a.OccurrenceId) .ToDictionary( k => k.Key, v => v.Select(a => new ScheduledIndividual { ScheduledAttendanceItemStatus = Attendance.GetScheduledAttendanceItemStatus(a.RSVP, a.ScheduledToAttend), Person = a.PersonAlias.Person, GroupMember = a.Occurrence.Group.Members.FirstOrDefault(gm => gm.PersonId == a.PersonAlias.PersonId), CurrentlyCheckedIn = a.DidAttend == true }) .ToList()); List <AttendanceOccurrence> attendanceOccurrenceList = attendanceOccurrenceQuery .Include(a => a.Schedule) .Include(a => a.Attendees) .Include(a => a.Group) .Include(a => a.Location) .AsNoTracking() .ToList() .OrderBy(a => a.OccurrenceDate) .ThenBy(a => a.Schedule.Order) .ThenBy(a => a.Schedule.GetNextStartDateTime(a.OccurrenceDate)) .ThenBy(a => a.Location.Name) .ToList(); var occurrenceRosterInfoList = new List <OccurrenceRosterInfo>(); foreach (var attendanceOccurrence in attendanceOccurrenceList) { var scheduleDate = attendanceOccurrence.Schedule.GetNextStartDateTime(attendanceOccurrence.OccurrenceDate); var scheduledIndividuals = confirmedScheduledIndividualsForOccurrenceId.GetValueOrNull(attendanceOccurrence.Id); if ((scheduleDate == null) || (scheduleDate.Value.Date != attendanceOccurrence.OccurrenceDate)) { // scheduleDate can be later than the OccurrenceDate (or null) if there are exclusions that cause the schedule // to not occur on the occurrence date. In this case, don't show the roster unless there are somehow individuals // scheduled for this occurrence. if (scheduledIndividuals == null || !scheduledIndividuals.Any()) { // no scheduleDate and no scheduled individuals, so continue on to the next attendanceOccurrence continue; } } var occurrenceRosterInfo = new OccurrenceRosterInfo { Group = attendanceOccurrence.Group, Location = attendanceOccurrence.Location, Schedule = attendanceOccurrence.Schedule, ScheduleDate = scheduleDate, ScheduledIndividuals = scheduledIndividuals }; occurrenceRosterInfoList.Add(occurrenceRosterInfo); } var mergeFields = LavaHelper.GetCommonMergeFields(this.RockPage); mergeFields.Add("OccurrenceList", occurrenceRosterInfoList); mergeFields.Add("DisplayRole", rosterConfiguration.DisplayRole); mergeFields.Add("OccurrenceDate", occurrenceDate); var rosterLavaTemplate = this.GetAttributeValue(AttributeKey.RosterLavaTemplate); var rosterHtml = rosterLavaTemplate.ResolveMergeFields(mergeFields); // by default, let's disable viewstate (except for when the configuration dialog is showing) lOccurrenceRosterHTML.ViewStateMode = viewStateMode; lOccurrenceRosterHTML.Text = rosterHtml; }
public object SaveViewStateRecursive(ViewStateMode mode) { return(PrivateInvoke.InvokeNonPublicMethod(_control, typeof(Control), "SaveViewStateRecursive", new object[] { mode })); }