title: FindControl Returning Null
body: <p>I am trying to contol a buttons state depending on a relevant text box. The names are the same other than the prefixes. The text boxes and buttons are located in a table on the page.</p>
  
  <pre><code>&lt;asp:Table ID="Table1" runat="server" CssClass="table"&gt;
              &lt;asp:TableRow&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:Label ID="lblRequestHeader" runat="server" Text="Requested" CssClass="bold text-center"
                          Width="90%"&gt;&lt;/asp:Label&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:Label ID="lblApprovalHeader" runat="server" Text="Approval" CssClass="bold text-center"
                          Width="90%"&gt;&lt;/asp:Label&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:Label ID="lblApprovalTimeHeader" runat="server" Text="Date/Time of Approval"
                          CssClass="bold text-center" Width="90%"&gt;&lt;/asp:Label&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:Label ID="lblReadyHeader" runat="server" Text="Ready To Pick Up" CssClass="bold text-center"
                          Width="90%"&gt;&lt;/asp:Label&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:Label ID="lblCollectedHeader" runat="server" Text="Collected By TestHouse" CssClass="bold text-center"
                          Width="90%"&gt;&lt;/asp:Label&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:Label ID="lblDeliveredHeader" runat="server" Text="Delivered From TestHouse"
                          CssClass="bold text-center" Width="90%"&gt;&lt;/asp:Label&gt;
                  &lt;/asp:TableCell&gt;
              &lt;/asp:TableRow&gt;
              &lt;asp:TableRow&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:TextBox ID="txtRequestTime" runat="server" Width="90%"&gt; &lt;/asp:TextBox&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:TextBox ID="txtApproval" runat="server" Width="90%"&gt;&lt;/asp:TextBox&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:TextBox ID="txtApprovalTime" runat="server" Width="90%"&gt;&lt;/asp:TextBox&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:TextBox ID="txtReadyTime" runat="server" Width="90%"&gt;&lt;/asp:TextBox&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:TextBox ID="txtCollectedTime" runat="server" Width="90%"&gt;&lt;/asp:TextBox&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:TextBox ID="txtDeliveredTime" runat="server" Width="90%"&gt;&lt;/asp:TextBox&gt;
                  &lt;/asp:TableCell&gt;
              &lt;/asp:TableRow&gt;
              &lt;asp:TableRow&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:Button ID="btnReadyTime" runat="server" Text="Ready To Collect" Width="90%" /&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:Button ID="btnCollectedTime" runat="server" Text="Collected" Width="90%" /&gt;
                  &lt;/asp:TableCell&gt;
                  &lt;asp:TableCell Width="15%"&gt;
                      &lt;asp:Button ID="btnDeliveredTime" runat="server" Text="Delivered" Width="90%" /&gt;
                  &lt;/asp:TableCell&gt;
              &lt;/asp:TableRow&gt;
          &lt;/asp:Table&gt;
  </code></pre>
  
  <p>The textbox is populated by a dataretrieval, and the state of the button is then set by the called method as follows:</p>
  
  <pre><code>txtReadyTime.Text = slabdetails.ReadyTimestamp.ToString();
  textboxenabled(txtReadyTime);
  </code></pre>
  
  <p>This method modifies the textbox name to a button name, then attempts to find the button to enable/disable it.</p>
  
  <pre><code> public void textboxenabled(TextBox box)
      {
         string btnName = box.ID.Replace("txt", "btn");
          try
          {
              Button btn = FindControl(btnName) as Button;
              if (box.Text == "")
                  btn.Enabled = true;
              else
                  btn.Enabled = false;
          }
          catch
          {
          }
      }
  </code></pre>
  
  <p>However, despite the string matching the names of the buttons perfectly, the control returns as null. 
  What can be done to deal with this issue?</p>