There is a aspx page which makes use of UserControl as follows.
Page1.aspx.cs
public class Page1
{
  public string Code {get;set;}
 ....
}
In the Page1.aspx a user control called "UsrControl"
<@Register TagPrefix="Usr" NameSpace="UsrControl">
I have the following code in UsrControl.
 public class UsrControl : Label
    {
      private Page1 _page1;
      
     protected override void OnInit(EventArgs e)
      {
        _page1 = (Page1)Page;
        string test = _page1.Code;
      }
.....
    }
In the usercontrol , the parent page is harcoded and from there the property of parent page (Page1) is being used .
Now the thing is I have one more aspx page Page2 which has same set of properties as Page1(Code) needed to invoke "UsrControl"
How can I refactor "UsrControl" to have the capability of accepting Page1 and Page2 and execute the code ? Should reflection be used?
 
     
    