title: Hiding login panel in master page when users logged in. (ASP.net)
body: <p>I have a panel in my master page that has textboxes for users login. Users logged in successfully but I want to hide panel .when users entered when I try to hide hide panel by false the visibility this doesn't work. My codes in master pages below: ( I use forms authentication and users are in data base)</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
      //hide panel doesn't work
      Panel1.Visible = false;
      //
      SqlCommand cmd = new SqlCommand();
      string str = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\ava\\Desktop\\WebSite3\\App_Data\\news.mdf;Integrated Security=True;User Instance=True";
      SqlConnection conn = new SqlConnection(str);
      conn.Open();
      cmd.CommandText = "select * from users where username=@name and pass=@pass";
      cmd.Connection = conn;
      cmd.Parameters.AddWithValue("name", user.Text);
      cmd.Parameters.AddWithValue("pass", pass.Text);
  
      SqlDataReader dr = cmd.ExecuteReader();
  
      if (dr.HasRows)
      {
          Panel1.Visible = false;
          Panel2.Visible = true;
  
          FormsAuthentication.SetAuthCookie(user.Text, true);
          FormsAuthentication.RedirectFromLoginPage(user.Text, true);
          Response.Redirect("/website3/karbar/karbar.aspx");
  
  
      }
      else user.Text = "Incorrect name or pass";
  }
  </code></pre>