protected void Page_Load(object sender, EventArgs e)
        {
            // TODO: refactor - similar code

            // Validate challenge
            if (!String.IsNullOrEmpty(SelectedChallenge))
            {
                Item challenge = FindChildById(Constants.ChallengesContainer, SelectedChallenge);
                if (challenge == null)
                {
                    // TODO: display error
                    return;
                }

                _challenge = new ChildChallengeItem(challenge);
            }

            // Validate grade
            if (!String.IsNullOrEmpty(SelectedGrade))
            {
                Item grade = FindChildById(Constants.GradeContainer, SelectedGrade);
                if (grade == null)
                {
                    // TODO: display error
                    return;
                }

                _grade = new GradeLevelItem(grade);
            }

            BindEvents();
            BindContent();
            BindResults();
        }
Пример #2
0
        private void BindContent()
        {
            if (Session[Constants.SessionBehaviorSearchKey] != null)
            {
                SessionSearchResult ssr = (SessionSearchResult)Session[Constants.SessionBehaviorSearchKey];

                bool hasResults = ssr.Results.Any();

                hlBackToSearch.Visible = hasResults;
                phResultNav.Visible    = ssr.Results.Count > 1;

                if (hasResults)
                {
                    Item item = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(ssr.Challenge));
                    ChildChallengeItem challenge = item;
                    litSearchChallenge.Text = String.Format("{0} {1}", DictionaryConstants.BackToFragment, challenge.ChallengeName.Text);

                    hlBackToSearch.Visible     = true;
                    hlBackToSearch.NavigateUrl = FormHelper.GetBehaviorResultsUrl(ssr.Challenge, ssr.Grade);

                    var currentItem = Sitecore.Context.Item;
                    var next        = ssr.GetNextResult(currentItem.ID);
                    var prev        = ssr.GetPreviousResult(currentItem.ID);

                    PopulateLink(next, hlNext);
                    PopulateLink(prev, hlPrev);

                    phNavLabel.Visible = hlNext.Visible || hlPrev.Visible;
                }
            }
        }