Load a page's control collection via code - ASP.NET C#
<p>I am trying to write a method that will dynamically load a given page's control collection so I can iterate through it and create a list of certain types of controls that reside on the page.  The idea is that for any page that inherits from a particular page class, I want to compile a list of editable fields with certain attributes.  This all happens outside of these pages (on a different page that is allowing users to manage these other pages).  </p>

<p>I've tried both of the following scenarios:</p>

<pre><code>BasePage page = (BasePage)System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(string.Format("~/Pages/{0}/Manage.aspx", type.ToString()), typeof(BasePage));

IHttpHandler handler = PageParser.GetCompiledPageInstance(string.Format("~/Pages/{0}/Manage.aspx", type.ToString()), Context.Server.MapPath(string.Format("~/Pages/{0}/Manage.aspx", type.ToString())), HttpContext.Current);
BasePage page = handler as BasePage;
</code></pre>

<p>In both situations, the page variable is initiated but the controls collection is blank, presumably because both of these methods are only loading the codebehind and not the markup.  How can I dynamically load the page's control collection?</p>
