If you try to call an ASP.NET control from the constructor in C# page, you will get a null exception. This is because the control really did not get initialized at this point or the value was not yet assigned to it. So the constructor in ASP.NET page is really limited of what it can do.
To initialized variable from textboxes or other controls on page, use Page_load(Object Sender, EventArgs e) function
Page_load(Object Sender, EventArgs e) { /* Initialize your variables here */ name = txtStudentName.text; /* for example */ }