protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int  studId           = CurrentSession.CurrStudent.StudentId;
                int  CourseId         = CurrentSession.CurrStudent.Product.UniqueId;
                int  SemId            = CurrentSession.CurrStudent.ExamResultDetail.Semester.SemesterId;
                int  SchId            = CurrentSession.CurrStudent.ExSchId;
                int  ResDetId         = CurrentSession.CurrStudent.ExamResultDetail.ExmResultDetailId;
                bool isModExam        = CurrentSession.CurrStudent.isModExam;
                ExamUserComponent euc = new ExamUserComponent();
                int success           = 0;

                success = euc.GenerateQuestions(studId, CourseId, SchId, ResDetId, SemId, isModExam);

                rdbtnQuesNo.DataSource = euc.GetQuestionaires(1, "1", 1, studId, ResDetId, 0, 0, isModExam);
                rdbtnQuesNo.DataBind();
                rdbtnQuesNo.SelectedIndex = 0;
                //GetQuestions();
                int SeqNo = Convert.ToInt32(rdbtnQuesNo.SelectedItem.Text);

                SaveAnswerAndGetQuestion(1, "NoSave", 1, studId, ResDetId, SeqNo, 0, isModExam);
                divPrev.Visible = false;

                CurrentSession.ExamPrevId = rdbtnQuesNo.SelectedValue;
                //hdnPrevExamDetId.Value = rdbtnQuesNo.SelectedValue;
                //Session["PrevExamDetId"] = rdbtnQuesNo.SelectedValue;
                //ViewState["seconds"] = 0;
                hdnDuration.Value = CurrentSession.CurrStudent.Duration.ToString();
            }
        }
        private void SaveAnswerAndGetQuestion(int ExamDetId, string Answer, int TypeId, int StudId, int ResDetId, int SeqId = 0, int fin = 0, bool isModExam = false)
        {
            ExamUserComponent euc = new ExamUserComponent();

            List <QnStudentExamDet> lstExamDet = new List <QnStudentExamDet>();

            lstExamDet = euc.GetQuestionaires(ExamDetId, Answer, TypeId, StudId, ResDetId, SeqId, fin, isModExam);

            if (fin != 1)
            {
                lblMarks.Text = "Marks : " + lstExamDet[0].QuestionMaster.Marks.ToString();
                lblQues.Text  = Server.HtmlEncode(lstExamDet[0].QuestionMaster.Description);
                string QuesNo;
                QuesNo             = rdbtnQuesNo.SelectedItem.Text;
                lblQuestionNo.Text = "Question No : " + QuesNo;
                lblTypeId.Text     = lstExamDet[0].TypeId.ToString();
                if (lstExamDet[0].TypeId == 1)
                {
                    rdbtnAns.Visible    = true;
                    chkAns.Visible      = false;
                    rdbtnAns.DataSource = lstExamDet;
                    rdbtnAns.DataBind();
                    foreach (ListItem rdnlst in rdbtnAns.Items)
                    {
                        rdnlst.Text = Server.HtmlEncode(rdnlst.Text);
                    }
                    foreach (QnStudentExamDet _examDet in lstExamDet)
                    {
                        if (_examDet.isSelected == true)
                        {
                            rdbtnAns.SelectedValue = _examDet.OptionSeqNo.ToString();
                            break;
                        }
                    }

                    //Abdul
                    if (lstExamDet[0].QuestionMaster.ImgFileName != null)//code to show image from solution folder
                    {
                        //string path = Server.MapPath("~/QuestImage/" + lstExamDet[0].QuestionMaster.ImgFileName);
                        string path = ConfigurationManager.AppSettings["QstImgUrl"].ToString() + lstExamDet[0].QuestionMaster.ImgFileName;

                        if (File.Exists(path))
                        {
                            plnImage.Visible = true;

                            string photoName = lstExamDet[0].QuestionMaster.ImgFileName;
                            string filenopic = string.Format("~/QuestImage/" + photoName, photoName, "e");
                            imgPhoto.ImageUrl = path; //filenopic;
                        }
                        else
                        {
                            plnImage.Visible = false;
                        }
                    }
                    else
                    {
                        imgPhoto.ImageUrl = "";
                        plnImage.Visible  = false;
                    }

                    //Abdul
                }
                else
                {
                    rdbtnAns.Visible  = false;
                    chkAns.Visible    = true;
                    chkAns.DataSource = lstExamDet;
                    chkAns.DataBind();
                    foreach (ListItem chklst in chkAns.Items)
                    {
                        chklst.Text = Server.HtmlEncode(chklst.Text);
                    }
                    int i;
                    for (i = 0; i < lstExamDet.Count; i++)
                    {
                        if (chkAns.Items[i].Value == lstExamDet[i].OptionSeqNo.ToString())
                        {
                            if (lstExamDet[i].isSelected)
                            {
                                chkAns.Items[i].Selected = true;
                            }
                        }
                        //if (_examDet.isSelected == true)
                        //    chkAns.SelectedValue = _examDet.OptionSeqNo.ToString();
                    }
                    //Abdul
                    if (lstExamDet[0].QuestionMaster.ImgFileName != null)//code to show image from solution folder
                    {
                        string newpath = Server.MapPath("~/QuestImage/" + lstExamDet[0].QuestionMaster.ImgFileName);
                        string srcPath = ConfigurationManager.AppSettings["QstImgUrl"].ToString() + lstExamDet[0].QuestionMaster.ImgFileName;

                        getImage(srcPath, newpath);
                        if (File.Exists(newpath))
                        {
                            plnImage.Visible = true;

                            string photoName = lstExamDet[0].QuestionMaster.ImgFileName;
                            string filenopic = string.Format("~/QuestImage/" + photoName, photoName, "e");
                            imgPhoto.ImageUrl = filenopic;
                        }
                        else
                        {
                            plnImage.Visible = false;
                        }
                    }
                    else
                    {
                        imgPhoto.ImageUrl = "";
                        plnImage.Visible  = false;
                    }
                    //Abdul
                }
            }
        }