protected override void OnPreLoad(EventArgs e) { base.OnPreLoad(e); StateCode = ViewStateStateCode; CountyCode = ViewStateCountyCode; LocalCode = ViewStateLocalCode.TwoCharLocalCode(); StateCodeExists = StateCache.IsValidStateCode(StateCode); if (StateCodeExists) { StateCodeIsNonState = false; if (string.IsNullOrWhiteSpace(CountyCode)) { AdminPageLevel = AdminPageLevel.State; CodesAreValid = true; } else // we have a CountyCode { AdminPageLevel = AdminPageLevel.County; CountyCodeExists = Counties.StateCodeCountyCodeExists(StateCode, CountyCode); if (CountyCodeExists) { if (string.IsNullOrWhiteSpace(LocalCode)) { CodesAreValid = true; } else { AdminPageLevel = AdminPageLevel.Local; LocalCodeExists = LocalDistricts.StateCodeCountyCodeLocalCodeExists(StateCode, CountyCode, LocalCode.TwoCharLocalCode()); CodesAreValid = LocalCodeExists; } } } } else { var nonStateCodesAllowed = NonStateCodesAllowed; var nonStateCodesRequireSuperUser = NonStateCodesRequireSuperUser; if (nonStateCodesAllowed != null && nonStateCodesAllowed.Contains(StateCode) && (IsSuperUser || nonStateCodesRequireSuperUser == null || !nonStateCodesRequireSuperUser.Contains(StateCode))) { StateCodeExists = true; CodesAreValid = true; switch (StateCode) { case "US": AdminPageLevel = AdminPageLevel.President; break; case "PP": AdminPageLevel = AdminPageLevel.PresidentTemplate; break; case "U1": case "U2": case "U3": case "U4": AdminPageLevel = AdminPageLevel.Federal; break; case "": case "LL": AdminPageLevel = AdminPageLevel.AllStates; break; default: StateCodeExists = false; CodesAreValid = false; break; } } } }