Click here to Skip to main content
15,908,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Result page code as follows;

In result page in page load code as follows;
C#
 protected void Page_Load(object sender, EventArgs e)
 {

   try
   {
       Int32 Avg;
       Avg = Convert.ToInt32(Session["Avg"]);
       BtnReExam.Text = "Next Candidate";
       Image1.ImageUrl = "images/Congratulation.gif";
       Image1.Visible = true;
       if (Avg >= 90 && Avg <= 100)
           Label2.Text = "Excellent  " + Session["StudName"] + "  Congrats";
       else if (Avg >= 75 && Avg <= 90)
           Label2.Text = "Very Good  " + Session["StudName"] + "  Congrats";
       else if (Avg >= 60 && Avg <= 75)
           Label2.Text = "Good  " + Session["StudName"] + "  Congrats";
       else if (Avg < 60)
        Label2.Text = "Sorry " + Session["StudName"] + ". You are Failed. You have to attend the Re-Exam Now.";
           BtnReExam.Text = "Press here to Start Re-Exam";
           Image1.ImageUrl = "";
           Image1.Visible = false;
       //}
       Label1.Text = "You scored " + Avg + "% of marks";
       Session.Clear();
       Session.RemoveAll();
   }
   catch (Exception ex1)
   {
       this.Label4.Text = ex1.Message.ToString();
       return;
   }
}



Button ReExam code as follows

C#
protected void BtnReExam_Click(object sender, EventArgs e)
{
     Int32 Avg;
     Avg = Convert.ToInt32(Session["Avg"]);
     if (Avg < 60)
     {
         string studname = "";
         string studid = "";
         studname = Session["StudName"].ToString();
         studid = Session["StudID"].ToString();
         Session.Clear();
         Session.RemoveAll();
         Session["StudName"] = studname.ToString();
         Session["StudID"] = studid.ToString();
     }
     else
     {
         Session.Clear();
         Session.RemoveAll();
     }
       Response.Redirect("login.aspx");
}



when i run and attend the exam if student fails, then that student id and name want to display in the login page.

for that i written a code in Button (Rexam).

In the result page, page load i written if student fails means session clear,
but i want the student id and student name values do not want to clear in the session

when student fails i want to display the student name and student id in the login page.

for that how can ido?

from my above code in the result page, page load what is the problem

please help me.

Regards,
Narasiman P.
Posted
Updated 6-May-13 18:59pm
v3

1 solution

You are using
C#
Session.Clear();
Session.RemoveAll();


it will clear and remove all the Session Variables

try to remove particular sessions using
Session.Remove("Session Name");

if you are getting errors on page load, check weather the session variables you are using are NULL or not
Example->
C#
if (Session["Session Name"] != null)
        {
            Label2.Text = Session["Session Name"].ToString();
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900