System.NullReferenceException: 未将对象引用设置到对象的实例
小弟刚学asp,很多都不懂
我在调试一个asp页面的时候发生如下错误:希望各位大虾帮帮忙,找找那里出错了,
根据这个例子,怎样把对象引用设置到对象的实例啊??????
“/examOline”应用程序中的服务器错误。
--------------------------------------------
未将对象引用设置到对象的实例。  
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。  
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:  
行 22:     protected void btnlogin_Click(object sender, EventArgs e)
行 23:     {
行 24:         if (txtCode.Text.Trim() != Session["verify"].ToString())
行 25:         {
行 26:             Response.Write("<script>alert('验证码错误');location='Login.aspx'</script>");
  源文件: f:\wwwroot\examOline\Login.aspx.cs    行: 24  
堆栈跟踪:  
[NullReferenceException: 未将对象引用设置到对象的实例]
    Login.btnlogin_Click(Object sender, EventArgs e) in f:\wwwroot\examOline\Login.aspx.cs:24
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
我的login.aspx.cs源码如下;
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//51aspx
public partial class Login : System.Web.UI.Page
{
     protected void Page_Load(object sender, EventArgs e)
     {
         if (!IsPostBack)
         {     Session["accountMode"] = "id";    }
     }
     protected void btnlogin_Click(object sender, EventArgs e)
     {
         if (txtCode.Text.Trim() != Session["verify"].ToString())
         {
             Response.Write("<script>alert('验证码错误');location='Login.aspx'</script>");
         }
         else
         {
             if (this.ddlstatus.SelectedValue == "学生")
             {
                 if (BaseClass.CheckStudent(txtNum.Text.Trim(), txtPwd.Text.Trim()))
                 {
                     Session["studentID"] = txtNum.Text.Trim();
                     Response.Redirect("student/student.aspx");
                 }
                 else
                 {
                     Response.Write("<script>alert('您不是学生或者用户名和密码错误');location='Login.aspx'</script>");
                 }
             }
             if (this.ddlstatus.SelectedValue == "教师")
                 {
                     string mode=Session["accountMode"].ToString();
                     if (mode=="id")
                     {
                         if (BaseClass.CheckTeacher(txtNum.Text.Trim(), txtPwd.Text.Trim()))
                         {
                             Session["teacherID"] = txtNum.Text;
                             Response.Redirect("teacher/Teacher.aspx");
                         }
                         else
                         {