title: Identify Label and Button Control in each page of the web project
body: <p>I am trying one more time to reach out to asp.net experts and hoping to get an answer. I am really stuck here and asking for help. Hopefully, my question will not get down voted, and I could get an answer purely from technical point of view instead of people simply being judgmental on my approach. </p>
  
  <p>Earlier I posted question as follows:
  <a href="https://stackoverflow.com/questions/11422501/asp-net-convert-asp-net-page-into-page-variable">asp.net convert asp.net page into Page variable</a></p>
  
  <p>Then I looked at following page but still its not working for me.</p>
  
  <p><a href="https://stackoverflow.com/questions/376404/load-an-asp-net-2-0-aspx-page-using-system-reflection">Load an ASP.NET 2.0 aspx page using System.Reflection?</a></p>
  
  <p>Inside my web application, I would like to be able to reference web pages any where in my code like "WebForm1.aspx" and get a listing of the controls on that page. Please just look at it from this point of view and not over analyze it. Is it possible? </p>
  
  <p>In my Page variable p, I do not seem to have any controls for WebForm1.aspx</p>
  
  <p>Here is my code. </p>
  
  <p>Please help.</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
      {
          string[] filePaths = Directory.GetFiles(Server.MapPath("~/"), "*.*", SearchOption.AllDirectories);
  
          foreach (string filepath in filePaths)
          {
              if (filepath.EndsWith(".aspx"))
              {
                  Response.Write(filepath + "&lt;br/&gt;");
  
                  string[] folders = filepath.Split('\\');
                  string filename = folders[folders.Count() - 1];
                  string fullpath = "~/" + filename;
  
                  Page p = BuildManager.CreateInstanceFromVirtualPath("~/"+fullpath, typeof(Page)) as Page;
  
                  List&lt;String&gt; controlList = new List&lt;String&gt;();
                  ResourceManager.AddControls(p.Controls, controlList);
  
                  foreach (string str in controlList)
                  {
                      Response.Write(str + "&lt;br/&gt;");
                  }
  
  
              }
          }
  </code></pre>