title: Web User Control with content inside it
body: <p>Usage :</p>
  
  <pre><code>    &lt;uc1:WindowControl ID="Window_ExpoNews" runat="server" Height="265px" Title="Expo News"
      Width="100%"&gt;              
      &lt;ContentTemplate&gt; 
          This content will show in the center cell of this user control.
          &lt;br /&gt;
          I can even add real controls.
          &lt;asp:TextBox ID="TextBox1" runat="server" /&gt;
          &lt;br /&gt;
          Good times.
      &lt;/ContentTemplate&gt;
  &lt;/uc1:WindowControl&gt; 
  </code></pre>
  
  <p>Control's source :</p>
  
  <pre><code> &lt;asp:Panel ID="Panel2" 
             runat="server"&gt;                 
         &lt;/div&gt;
  &lt;/asp:Panel&gt;
  &lt;asp:PlaceHolder runat="server" ID="BodyControlSpace"/&gt;
  </code></pre>
  
  <p>
  Code Behind :</p>
  
  <pre><code>public partial class Componants_WebUserControl : System.Web.UI.UserControl{
  
  private ITemplate _ContentTemplate;
  
  [PersistenceMode(PersistenceMode.InnerProperty)]
  public ITemplate ContentTemplate
  {
      get { return _ContentTemplate; }
      set { _ContentTemplate = value; }
  }
  
  protected override void OnInit(EventArgs e)
  {
      base.OnInit(e);
      _ContentTemplate.InstantiateIn(BodyControlSpace); 
  } 
  
  public Unit Width
  {
      get {return Panel1.Width;}
      set {Panel1.Width = value;}
  }
  
  public Unit Height
  {
      get {return Panel1.Height;}
      set {Panel1.Height = value;}
  }
  
  public string Title
  {
      get {return lblTitle.Text;}
      set {lblTitle.Text = value;}
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The problem is it gives me following error :<br /> 
  Object reference not set to an instance of an object. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br /> </p>
  
  <p>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.<br /> </p>
  
  <p>Source Error: <br /> </p>
  
  <p>Line 21:     { <br /> 
  Line 22:         base.OnInit(e); <br /> 
  Line 23:         _ContentTemplate.InstantiateIn(BodyControlSpace); <br /> 
  Line 24:     } <br /> 
  Line 25: <br /> </p>