title: asp:Literal control null in user control
body: <p>I've a user control which contains asp:Literal. </p>
  
  <pre><code>&lt;div&gt;
       &lt;asp:Literal id="MenuContainer" runat="server" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>There is a method in code-behind page which initializes the control:</p>
  
  <pre><code>internal void Setup(MyBusinessObject obj)
  {
      MenuObject menu = MenuHelper.GetMenu(obj.State);
  
      if(obj == null)
          MenuContainer.Visible = false;
  
      //other code
  }
  </code></pre>
  
  <p>In the page where the control is used I call <strong>Setup</strong> method of control in <strong>LoadComplete</strong> event handler (I was first calling it in <em>Load</em> event). Irrespective of <em>MyBusinessObject</em> being null or not null, when I access <em>Literal</em> on user-control I get error:</p>
  
  <pre><code>Object reference not set to an instance of an object.
  </code></pre>
  
  <p>What is the reason and what is the remedy for this?</p>