title: Using a user control in a base page class
body: <p>I have a base page class that inherits from Page. We'll call it SpiffyPage.</p>
  
  <p>I also have a user control called SpiffyControl.</p>
  
  <p>I then have an aspx page, ViewSpiffyStuff.aspx, that inherits from SpiffyPage. </p>
  
  <p>On page load, the SpiffyPage class is supposed to inject a SpiffyControl into the aspx page.</p>
  
  <p>The problem is that SpiffyControl is a user control, and to instantiate that in the code behind one has to access the ASP namespace, sort of like:</p>
  
  <pre><code>ASP.controls_spiffycontrol_aspx MyControl;
  </code></pre>
  
  <p>But SpiffyPage isn't an aspx page, it's just a base page, and as such I can't access the ASP namespace, and I therefore can't instantiate a SpiffyControl in order to inject it.</p>
  
  <p>How can I achieve my goal?</p>
  
  <p>Edit:</p>
  
  <p>One important point is that I must have a reference to the actual control type so I can assign values to certain custom Properties. That's why a function like LoadControl, which returns type Control, won't work in this case.</p>