title: How to find user control of an ASP.NET page inside of event of another user control on that ASP.NET page EDIT: different content placeholders?
body: <p>I have a ASP.NET page with 2 user controls registered. The first one has only one button in it. The second one is simple text and hidden on default. What I want is to make the second one visible when the button in the first one is clicked (that is on button click event). </p>
  
  <p>ASP.NET page:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" CodeFile="test.aspx.cs" Inherits="test" %&gt;
  &lt;%@ Register Src="~/UC_button.ascx" TagName="button" TagPrefix="UC" %&gt;
  &lt;%@ Register Src="~/UC_text.ascx" TagName="text" TagPrefix="UC" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="MyTestContent" Runat="Server"&gt;
      &lt;UC:button ID="showbutton1" runat="server" /&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MyTestContent2" Runat="Server"&gt;
      &lt;UC:text runat="server" Visible="false" ID="text1" /&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>UC_Button.ascx.cs:</p>
  
  <pre><code>protected void button1_Click(object sender, EventArgs e)
  {
      Button btnSender = (Button)sender;
      Page parentPage = btnSender.Page;
      UserControl UC_text = (UserControl)parentPage.FindControl("text1");
      UC_text.Visible = true;
  }
  </code></pre>
  
  <p>What am I doing wrong?  I get well known <code>Object reference not set to an instance of an object.</code> error on that last line of the code.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>One thing I forgot to mention when first posting this. User controls are in different <code>&lt;asp:Content&gt;&lt;/asp:Content&gt;</code> controls (I edited upper example). If I put them in the same placeholder code works just fine. If I put them in the separate content placeholders I can't find them in any way with findcontrol. Why is that and how can I find them?</p>