title: Calling a parent page code behind method from a child page code behind - ASP.NET 2.0 Page Inheritance model
body: <p>What would be the best way to call a method in the code-behind of parent page from the code behind of the child page in the ASP.NET 2.0 Web Site model?</p>
  
  <p><b>Scenario:</b> User clicks a link in the parent page to view a data record's detail in child page (The parent and child are tow seperate pages).  The user will modified the data in the client page.  Once the child page has processed the update, the child page will close and I need to rebind the parent page to reflect the update.</p>
  
  <p>I did something similar, but it was calling the parent page from a user control that was included in the parent page</p>
  
  <pre><code>if(Page.GetType().ToString().Contains("ASP.Default_aspx"))
  {
      MethodInfo MyMethod = this.Parent.TemplateControl.GetType().GetMethod("MyMethod");
      MyMethod.Invoke(this.Page, null);
      MyMethod = null;
  }
  </code></pre>
  
  <p><b>UPDATE:</b> I have to do this from the code behind because the child page closes after the data has been updated.  </p>