title: asp.net panel control visibility issue
body: <p>I have written a code which checks unique ID availability status.. if ID is available it should make panel visible otherwise the panel visibility is hidden. But it is not working. If i set panel visibility to false in page load it works.. but panel visibility code inside text change event of textbox, doesnt work. In my view page script manager is present to update content inside update panel. What am i doing wrong.</p>
  
  <pre><code>&lt;asp:ScriptManager ID="scriptmanager1" runat="server"&gt;
  &lt;/asp:ScriptManager&gt;
  &lt;div&gt;
  &lt;asp:UpdatePanel ID="PnlUsrDetails" runat="server"&gt;
     &lt;ContentTemplate&gt;
       &lt;table&gt;
         &lt;tr&gt;
             Enter unique no: &lt;asp:TextBox ID="txtUniqueNo" runat="server" AutoPostBack="true" ontextchanged="txtUniqueNo_TextChanged"/&gt;      
         &lt;/tr&gt;
         &lt;tr&gt;
             &lt;div id="checkusername" runat="server"  Visible="false"&gt;
                &lt;asp:Image ID="imgstatus" runat="server" Width="17px" Height="17px"/&gt;
                &lt;asp:Label ID="lblStatus" runat="server"&gt;&lt;/asp:Label&gt;
             &lt;/div&gt;
         &lt;/tr&gt;
       &lt;/table&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  
  &lt;asp:Panel ID="Panel1" runat="server"&gt;
            &lt;div&gt;Panel content&lt;/div&gt;
  &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>server side code:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
  
      if (!this.Page.IsPostBack)
      {
          Panel1.Visible = false; 
          PopulateCategory();
          getSubCategories(CategoryDropDownList.SelectedValue);
          //CategoryDropDownList_SelectedIndexChanged(null, null);
      }
  }
  
  protected void txtUniqueNo_TextChanged(object sender, EventArgs e)
  {
      if (!string.IsNullOrEmpty(txtUniqueNo.Text))
      {
          OdbcConnection conn = new OdbcConnection(DB.DatabaseConnString());
          if (conn.State == ConnectionState.Open)
              conn.Close();
          conn.Open();
          OdbcCommand cmd = new OdbcCommand("select * from gallery where unique_no='" + txtUniqueNo.Text + "'", conn);
  
          OdbcDataReader dr = cmd.ExecuteReader();
          if (dr.HasRows)
          {
              checkusername.Visible = true;
              Panel1.Visible = false;
              imgstatus.ImageUrl = "~/images/unavailable.png";
              lblStatus.Text = "Unique Id Already Taken";
  
          }
          else
          {
              try
              {
                  checkusername.Visible = true;
                  Panel1.Visible = true;
                  imgstatus.ImageUrl = "~/images/tick.png";
                  lblStatus.Text = "Unique Id  Available";
              }
              catch (Exception ex)
              {
                  string mess = ex.Message;
              }
  
          }
      }
      else
      {
          checkusername.Visible = false;
      }
  }
  </code></pre>
  
  <p>My file upload is also in update panel,, which loses its file on upload. Suggest me any alternative approaches to achieve this functionality... 
  Thanks</p>