示例#1
0
        protected void uxSubmitbtn_Click(object sender, EventArgs e)
        {
            //create list for storing questions and answers
            List<QuestionAnswer> questionList = new List<QuestionAnswer>();

            //populate list with all questions and answers on the page
            foreach (Control c in uxQuestions.Controls)
            {
                if(c is ITestQuestion)
                {
                    ITestQuestion question = c as ITestQuestion;
                    QuestionAnswer qa = new QuestionAnswer();
                    qa.QuestionText = question.QuestionText;
                    qa.Answer = question.Answer;
                    questionList.Add(qa);
                }
            }

            //Save list to session
            Session["QuestionAnswers"] = questionList;

            //redirect to results page
            Response.Redirect("Results.aspx");
        }