title: how can i change content placeholder on button click?
body: <p>when i debugging i get a error message showing " Object reference not set to an instance of an object" . </p>
  
  <p>here is my code...............</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      ContentPlaceHolder cph1 = (ContentPlaceHolder)this.Page.Master.FindControl("ContentPlaceHolder1");
      ContentPlaceHolder cph2 = (ContentPlaceHolder)this.Page.Master.FindControl("ContentPlaceHolder2");
      cph1.Visible = true;
      cph2.Visible = false;
  }
  protected void Button1_Click(object sender, EventArgs e)
  {
      ContentPlaceHolder cph1 = (ContentPlaceHolder)this.Page.Master.FindControl("ContentPlaceHolder1");
      ContentPlaceHolder cph2 = (ContentPlaceHolder)this.Page.Master.FindControl("ContentPlaceHolder2");
      cph1.Visible = true;
      cph2.Visible = false;
  
      String ltype=DropDownList1.SelectedValue.ToString();
      momconnect obj = new momconnect();
      obj.getconnect();
      SqlCommand cmd1 = new SqlCommand("Select Levdef_id from Tbl_leave_define where Levtype='"+ltype+"'", obj.conn);
      SqlDataReader dr = cmd1.ExecuteReader();
      dr.Read();
      Session["defid"]=dr["Levdef_id"].ToString();
      dr.Close();
  
      SqlCommand cmd = new SqlCommand("sp_leave_request", obj.conn);
      cmd.CommandType = CommandType.StoredProcedure;
      cmd.Parameters.AddWithValue("@flag", 1);
      cmd.Parameters.AddWithValue("@Staff_id", Session["staffid"].ToString());
      cmd.Parameters.AddWithValue("@Levtype",ltype);
      cmd.Parameters.AddWithValue("@Reason",TextBox1.Text);
      cmd.Parameters.AddWithValue("@Num", TextBox2.Text);
      cmd.Parameters.AddWithValue("@Frmdate", TextBox3.Text);
      cmd.Parameters.AddWithValue("@Todate",TextBox4.Text);
      cmd.Parameters.AddWithValue("@Levdef_id", Session["defid"].ToString());
      cmd.ExecuteNonQuery();
  
      cph1.Visible = false;
      cph2.Visible = true;
      Label1.Text = "Leave request sent. Wait for approval";
  
  
  
  }
  </code></pre>