title: Factory Pattern for User Controls
body: <p>I created a ASP.NET user control, and was wanting to create a factory with a method that allowed a control to be created via several parameters.  </p>
  
  <p>Originally I was going to have a constructor on the user control with the parameters, but the parameters are really only provided to make creating the user control easier from some legacy code I don't want to change significantly.  I decided I wanted to instead have a method in a factory class that the legacy code could use, that way I don't muddy up the interface of my user control.</p>
  
  <p>The problem I have is I can't reference the user control class from the factory class(since normally you reference a user control programmatically by adding <code>&lt;%@ Reference Control="~/SomeControl.ascx" %&gt;</code> but the factory class isn't a asp page).</p>
  
  <p>On a side note I was going to have the calling page pass a reference to itself so that the factory method could call LoadControl, but I still need to be able to declare a SomeControl variable, which it cannot.</p>
  
  <p>How do I create a factory for a user control?</p>