title: Loading .aspx into a Panel/UpdatePanel
body: <p>I'm currently working on a web-based game using ASP.NET and C#. Previously, I've been just organizing the various game screens(start, hi-score, results, etc) into individual Panels nested within a main UpdatePanel and showing/hiding the appropriate Panels as the game progresses. However, I've severely underestimated the scale of the game and I'm gonna have to break it down to more manageable chunks.</p>
  
  <p>My idea now is to have a Main.aspx with an empty UpdatePanel and I'll load the various screens as individual .aspx files into it. Kinda like with WinForms I think, when you create another new WinForm and add it to the current parent form.</p>
  
  <p>I've been trying to find how to get about doing this in the code-behind, but I'm still at a lost. I could probably do this with Response.Redirect, but then there would be the usual flicker when the new page loads, which is something I want to avoid.</p>
  
  <p>I did come across something interesting called a <a href="http://msmvps.com/blogs/omar/archive/2008/05/24/uframe-goodness-of-updatepanel-and-iframe-combined.aspx" rel="nofollow noreferrer">UFrame</a> but that seems to work in the HTML instead of the code-behind.</p>
  
  <p>I appreciate any help or suggestions in this matter, and apologize if this has been asked before. Thank you.</p>
  
  <p><strong>Edit:</strong> With regards to womp's answer, .ascx seem to be a step in the right direction for me. I successfully got my Startscreen control control up and running inside the Main.aspx. However, another problem has popped up, where the screen just goes blank when I try to add another usercontrol to a panel inside Main.aspx upon a button click.</p>
  
  <p>The event handler I have for a button in the Startscreen control is:</p>
  
  <pre><code>protected void Btn_Arcade_Click(object sender, EventArgs e)
      {
          this.Parent.Controls.Add(LoadControl("Arcade.ascx"));
  
      }
  </code></pre>
  
  <p>I'm not too sure if there's anything wrong with that, but the Parent in this case is basically what I called the GameContentPanel that resides within Main.aspx's UpdatePanel.</p>
  
  <p>I don't think it's a problem with the HTML fudging up either, since I tested it by loading it first instead of the Startscreen, and everything showed up fine.</p>
  
  <p>I've also tried loading both controls together at the start in Main.aspx, and both controls load correctly as well.</p>