Dear All,
I have one web application in ASP.NET C#.
Currently, I'm working to display Question from the QuestionList to the candidate.
I have created a stored procedure to get a list of Questions, which is global varaible.
Private List<QuestionInfo> _questionList;
public List<QuestionInfo> QuestionList
{
get
{
if(_questionList != null)
return _questionList;
else
_questionList =
QuestionDetailsController.Instance.ExamQuestionsGetRandomly(Module.TotalQuestions, QuestionLanguageID, PracticeModuleID).Select(item => item.Question).ToList();
return _questionList;
}
}
What I have tried:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindQuestion(_questionNumber);
Timer1.Enabled = true;
}
}
protected void BindQuestion(int nthQuestion)
{
if (nthQuestion <= QuestionList.Count())
{
QuestionInfo CurrentQuestion = QuestionList.ElementAt(nthQuestion);
if (CurrentQuestion != null)
{
lblNoOfQuestions.Text = string.Format("Question {0} of {1}", nthQuestion + 1, ExamQuestion.QuestionList.Count());
lblQuestionText.Text = CurrentQuestion.QuestionDetails.First().Details.Text.QuestionText;
}
}
}
I'm using Ajax UpdatePanel & Timer(to display time remaining).
I have three buttons, like Previous, Pause, Next.
Whenever I click Previous or Next button, the global variable is getting null & on timer_tick event, as well.
How can I stop global variables not to get null, on clicking the Next, previous(buttons) or TimerEvent.
Can anyone please help me.
Thanks in advance