title: Best way to pass control to parent/base class in ASP.NET
body: <p>I have an abstract BasePage class that each Page class inherits from. Apart from core functionality I'd like BasePage to cover repetitive tasks that almost all derived classes implement. To do this however the BasePage class would have to hold reference to controls (dropdownlist, gridview, menu...) which are defined in derived class.</p>
  
  <p>My question is what is the best way to pass control reference defined in derived Page class to parent class?</p>
  
  <p>None of the following really gives "best" solution:</p>
  
  <ol>
  <li><p>Base page to declare variable with name that is the same as control's Id on derived class. This forces the ASP.NET designer not to re-create the control on derived class. (I don't like this since derived class is forced to know and use hard-coded name)</p></li>
  <li><p>Create abstract property and force derived class to return control reference (CON: In some cases derived class might not include such control)</p></li>
  <li><p>Pass the control as function call parameter (CON: still requires repetitive code of function call. Function itself then doesn't even have to be on BasePage)</p></li>
  </ol>