I'm at my wits end. My code isn't keeping track of sessions in C#
I'm using a user control which should pick up the session data, but it doesn't.
Here's the user control:
[Serializable]
public partial class studentComments : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
string currStud;
if (Session["CS"] == null)
{
currStud = "50";
}
else
{
currStud = (string)Session["CS"];
}
lblHeader.Text = "Comments for Student " + currStud;
//display(currStud);
}
}
and here is the code in the initial aspx.cs page
try
{
student temp = studList.Find(o => o.student_id == studID);
Session["CS"] = "45";
PnlComment.Visible = true;
}
catch (NullReferenceException nre)
{
lblTest.Text = "Student does not exist!";
}
Obviously the user control is in the PnlComment control.
edit I'm actually having an object passed to the session but I changed it to a static string for testing purposes, hoping that would simplify things. Alas, the label keeps showing 50. Why isn't it showing 45?
Help?