Web UserControl and Visual Inheritance

  • Thread starter Thread starter Ben Fidge
  • Start date Start date
B

Ben Fidge

Hi

I have a situation where it would be very advantageous to
be able to derive a new web UserControl from an existing
one, making the bases server controls available to the
derived class (and therefore, visible to the user).

I know how to derive from a base class so that common
code is available to the derived class, but I need to UI
elements to be visible in the new usercontrol too.

Any ideas?

Ben
 
I believe that's impossible.
When you execute a page (view it in browser), your ASPX or ASCX content is
transformed into a classon the fly. This class is always inherited from the
codebehind (.cs).
As far as I know, you can't derive from ASPX or ASCX. Therefore you can't
create a derived user control that would include the visual parts of the
base one.
Your only choice is to add your controls programmatically in the codebehind
of the base class, and then inherit.

-Oleg.
 
Back
Top