title: Unable to get back textbox enable property set to true once it is set to false on textchanged event?
body: <p>I have a web form in which I am trying to set the textbox control property to false on textchanged event. I have multiple textbox's and I have taken these into a panel. Now I am checking a condition within the text changed event of the textbox. If the condition matches then there will be no change but if not then I will set the enable property of the textbox's within panel control to false.
  This is what I am doing-</p>
  
  <pre><code>&lt;asp:TextBox ID="TextBox1" runat="server" Width="150px" AutoPostBack="True" 
          ontextchanged="TextBox1_TextChanged"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:Panel ID="Panel1" runat="server"&gt;
              &lt;asp:TextBox ID="txt1" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;asp:TextBox ID="txt2" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;asp:TextBox ID="txt3" runat="server"&gt;&lt;/asp:TextBox&gt;
  &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>my cs code-</p>
  
  <pre><code>protected void TextBox1_TextChanged(object sender, EventArgs e)
      {
          SqlConnection cons1 = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
          cons1.Open();
          SqlCommand scmd1 = new SqlCommand("select name from tbl_names where name='"+TextBox1.Text+"'", cons1);
          SqlDataReader sdr1 = scmd1.ExecuteReader();
          if (sdr1.HasRows)
          {
              while (sdr1.Read())
              {
                  Panel1.Visible = true;
                  Control ctrl = new Control();
                  foreach (Control c in ctrl.Controls)
                  {
                      if (c is TextBox &amp;&amp; c.ID.StartsWith("txt"))
                          ((TextBox)c).ReadOnly = false;
                  }
              }
          }
          else
          {
              Panel1.Visible = true;
              Control ctrl1 = new Control();
              foreach (Control c in ctrl1.Controls)
              {
                  if (c is TextBox &amp;&amp; c.ID.StartsWith("txt"))
                      ((TextBox)c).ReadOnly = true;
              }
          }
          cons1.Close();
      }
  </code></pre>
  
  <p>Please guide me why this is not working?</p>